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
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,
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
>> >
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
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
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