pythonadvanced
Slotted Class
Advanced Python pattern: slotted-class
pythonPress ⌘/Ctrl + Shift + C to copy
class Point:
__slots__ = ('x', 'y')
def __init__(self, x: int, y: int):
self.x = x
self.y = y
p = Point(1, 2)
print(p.x + p.y)Use Cases
- advanced programming
- patterns
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonbeginner
Type Hints
Advanced Python pattern: type-hints
Best for: advanced programming
#python#advanced
pythonintermediate
Dataclass
Advanced Python pattern: dataclass
Best for: advanced programming
#python#advanced
pythonadvanced
Abc Abstract
Advanced Python pattern: abc-abstract
Best for: advanced programming
#python#advanced
pythonbeginner
Enum Types
Advanced Python pattern: enum-types
Best for: advanced programming
#python#advanced