ch25: simple enum metaclasses
This commit is contained in:
29
25-class-metaprog/evalsupport.py
Normal file
29
25-class-metaprog/evalsupport.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# tag::BEGINNING[]
|
||||
print('<[100]> evalsupport module start')
|
||||
|
||||
def deco_alpha(cls):
|
||||
print('<[200]> deco_alpha')
|
||||
|
||||
def inner_1(self):
|
||||
print('<[300]> deco_alpha:inner_1')
|
||||
|
||||
cls.method_y = inner_1
|
||||
return cls
|
||||
|
||||
# end::BEGINNING[]
|
||||
# tag::META_ALEPH[]
|
||||
class MetaAleph(type):
|
||||
print('<[400]> MetaAleph body')
|
||||
|
||||
def __init__(cls, name, bases, dic):
|
||||
print('<[500]> MetaAleph.__init__')
|
||||
|
||||
def inner_2(self):
|
||||
print('<[600]> MetaAleph.__init__:inner_2')
|
||||
|
||||
cls.method_z = inner_2
|
||||
|
||||
# end::META_ALEPH[]
|
||||
# tag::END[]
|
||||
print('<[700]> evalsupport module end')
|
||||
# end::END[]
|
||||
Reference in New Issue
Block a user