if (__name__ == '__main__'): main(sys.argv[1:])

François Pinard pinard at iro.umontreal.ca
Fri Apr 23 15:22:01 EDT 2004


(Note: this is about having a line `__metaclass__ = type' near the
beginning of a Python program.)

[Michael Hudson]
> I like my code to do things similar to what it looks like it's doing.
> To me,
>     class MyClass:
>         ...
> says "classic class".

I understand your concern.  But since I do not want classic classes
anymore in my code, I prefer to read all classes as new style, as
blindly as possible.  If I ever wanted to specify a class as old-style
(but I never had the need so far), I would write:

    from types import ClassType

    class MyOldClass:
        __metaclass__ = ClassType
        ...

Why would you want to specifically use classic classes in these days?

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list