- [Instructor] Python supports enumerations…just like other popular programming languages…and they're useful in a variety of scenarios.…Usually, they are used to assign easy-to-read names…to constant values in a program,…which increases the readability of your code.…They can also be used as hash values,…and you can iterate over them like…you would other iterables in Python.…Enumerations are defined using the class syntax,…so let's open up our sample code.…I'm going to open up enums_start here in my Classes folder,…and I'm going to define an enum…by first importing the enum class from the enum package.…
So I'll write from enum import Enum…then to define an enum, I'll create a new class…and use the enum class as the superclass.…So I'll write class and I'll use some fruits…as my enumeration examples,…and Enum will be my superclass.…All right, so let's assign some values…to our enum, and for this example…I'll just use some fruit names.…So I'll have APPLE equals one,…BANANA is two, and we'll have ORANGE be three,…and TOMATO is four, yes, it's a fruit,…
- Truth value testing
- Template strings
- Advanced Python functions
- Advanced collections
- Advanced classes and objects
- Python comprehensions: list, dictionary, and set
Skill Level Advanced
1. Python Language Features
2. Built-In Functions
3. Advanced Python Functions
4. Advanced Collections
5. Advanced Classes and Objects
6. Using Logging
7. Python Comprehensions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.