When and why might I assign an instance of a descriptor class to a class attribute in Python rather than use a property? -
i'm aware property is descriptor, there specific examples of when using descriptor class might more advantageous, pythonic, or provide benefit on using @property
on method function?
better encapsulation , re-usability: descriptor class can have custom attributes set on instantiating. it's useful keep data confined in manner, instead of having worry getting set or overwritten on descriptor's owner.
Comments
Post a Comment