Re: Is it dangeous when using custom metaclass?

2018-10-17 Thread dieter
jf...@ms4.hinet.net writes: > ... > Hard to find the document of type.__init__. I can only guess it does nothing, > at least no thing serious, to avoid trouble the metaclass's __init__ may > cause in a class hierarchy:-) You always have the possibility to look at the source. All classes have

Re: Is it dangeous when using custom metaclass?

2018-10-17 Thread jfong
dieter at 2018/10/17 UTC+8 PM 1:15:01 wrote: > jf...@ms4.hinet.net writes: > > Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > >> jf...@ms4.hinet.net wrote: > >> > class Structure(metaclass=StructureMeta): ... > >> > > >> > class PolyHeader(Structure): ... > >> > > >> > As my understanding,

Re: Is it dangeous when using custom metaclass?

2018-10-16 Thread dieter
jf...@ms4.hinet.net writes: > Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote >> jf...@ms4.hinet.net wrote: >> > class Structure(metaclass=StructureMeta): ... >> > >> > class PolyHeader(Structure): ... >> > >> > As my understanding, the metaclass's __init__ was called when a class was >> >

Re: Is it dangeous when using custom metaclass?

2018-10-16 Thread jfong
Gregory Ewing at 2018/10/16 UTC+8 PM 2:01:01 wrote > jf...@ms4.hinet.net wrote: > > class Structure(metaclass=StructureMeta): ... > > > > class PolyHeader(Structure): ... > > > > As my understanding, the metaclass's __init__ was called when a class was > > created. In the above example, both the

Re: Is it dangeous when using custom metaclass?

2018-10-16 Thread Gregory Ewing
jf...@ms4.hinet.net wrote: class Structure(metaclass=StructureMeta): ... class PolyHeader(Structure): ... As my understanding, the metaclass's __init__ was called when a class was created. In the above example, both the Structure and PolyHeader called it. My question is: because the PolyHeader

Is it dangeous when using custom metaclass?

2018-10-15 Thread jfong
class StructureMeta(type): def __init__(self, clsname, bases, clsdict): offset = 0 ... ... setattr(self, 'struct_size', offset) class Structure(metaclass=StructureMeta): ... ... class PolyHeader(Structure): ... ... As my understanding, the