In the previous episodes
- basic stuff, syntax
- functions (wrote our cool min function) + functional stuff
- scopes, PEP-8
- strings, bytes
- collections
- classes basics
- decorators, functools
- exceptions, context managers
- iterators, generators, itertools
🏛 Classes again
👇 Class
🏛 Classes basics wrap-up
Class decorator
Class and Object Attributes reminder
Inheritance reminder
Method override (inheritance reminder)
That’s it
base stuff class inheritance
The right way:
property reminder
Class methods
Class methods
Static methods
How? The answer is descriptors
Primer
🪄 Magic methods
🤔 equals?
🧐 __eq__
https://docs.python.org/3/reference/datamodel.html#special-method-names
🐍 NamedTuple
namedtuple reminder
and from dictionary
Why?
namedtuple wrap-up
- It looks and acts like an immutable object.
- It is more space and time efficient than objects.
- You can access attributes by using dot notation instead of dictionary-style square brackets.
- You can use it as a dictionary key.
🔥 dataclasses
Typical boilerplate:
dataclass helps:
👀 typing!
More dataclasses…
dataclass deeper: fields
more: https://www.python.org/dev/peps/pep-0557/
🍰 Metaclasses
more: https://realpython.com/python-metaclasses/
🏁 Any questions?