I have to be some data descriptor as part of a class. Which means that I want the class properties to be virtually the qualities, which should be accessed by class methods.
It seems that the dragon does not directly support it, but it can be implemented by subclassing> type class. Therefore, by adding an asset to the subclass of type , for its examples, there will be descriptors for that property, as its examples are squared, thus, the class descriptor.
Is this advice? Should I look for any pass?
This is a convention for a descriptor (usually), when reaching a class, To return itself to itself, this is what property does; If you access the property object on a category, you get the property object back (because it is exactly what it is to choose the __ get __ method). But this is a conference; you do not have to do that.
So, if you only need descriptor descriptor on your class, and you do not have any effort, the descriptor will be overwritten to set you, Some metaclos can be done with programming:
def classproperty_getter_only (f): class nonDataDescriptor (object): def __get __ (self, example, ICL): return F (ICLS) non data decryptter () Class Foo (object) Returns: @ ClassProperty_T Flat Print (CLS): Returns 'Hello to', CLS Print Foo.flip Print Fu () For flop
('hello ho', & lt; class '__main __.foo' & gt;) ('hello to' & Lt; class '__main __.foo' & gt;) If you want a full data descriptor, or want to use the built-in property object, then you are right You can use MetaCLASS and put it there (realize that this feature will be completely invisible from the examples of your class, Metaclasses are not being examined for a class A view tributes at the event).
Is this advice? I do not think I am describing you in the production code; I only consider it if I had a very compulsive reason to do this (and I can not think of such a scenario from above my head) Metaclasses are very powerful, but they all understand well by programmers. Not coming, and there is something more difficult about it, so their use makes it harder to maintain your code. I think the massive community design by the Dragon community This type of composition will be straightened.
Comments
Post a Comment