__metaclass__ = type (was: Re: if (__name__ == '__main__'): main(sys.argv[1:]))
Lee Harr
missive at frontiernet.net
Wed Apr 21 16:42:37 EDT 2004
On 2004-04-21, François Pinard <pinard at iro.umontreal.ca> wrote:
>
> __metaclass__ = type
>
> class Main:
> def __init__(self):
> pass
>
> A word about the `__metaclass__' line. My intent is to forget all about
> classic classes and go with the new type system as quickly as possible.
> I do not want to derive each and every of my classes from `object',
> and later edit all those `(object)' out when the classic classes will
> effectively get deprecated. Much easier and cleaner to remove that
> `__metaclass__' line then. Moreover, by using this `__metaclass__' line
> in all my things, I do not risk obscure bugs because I forgot one of
> these `object' derivation while I used more recent Python features.
>
Very interesting.
Is there any reason to stick with old-style classes? Or would we all
be well-advised to use something like this?
I mostly just create classes the old way and never even think about
subclassing object.
More information about the Python-list
mailing list