Re:Go Python, Go: Stream Processing for Python
by masklinn on Thursday October 12, 2017 @09:31AM
(#15457786)
> In regards to the 'name' being a function - a class attribute might indeed be more correct but a function allows for dynamic computation names where its applicable.
Accessing a simple attribute on the instance means it can be defined as any of a class attribute (instance will delegate to class), an instance attribute (computed/set in init) or a property (computed every time it's accessed), which is convenient, especially when the primary use case will be setting the name on the class directly.
In fact you could even fallback on the class name.
https://docs.python.org/3/library/functions.html#property
Accessing a simple attribute on the instance means it can be defined as any of a class attribute (instance will delegate to class), an instance attribute (computed/set in init) or a property (computed every time it's accessed), which is convenient, especially when the primary use case will be setting the name on the class directly.
In fact you could even fallback on the class name.