3 ms·
> 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 appli
by masklinn 9y ago
> 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.
https://docs.python.org/3/library/functions.html#property 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.