On 12 Jan 2005 20:06:39 -0800, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
>Simon Wittber <[EMAIL PROTECTED]> writes: >> > Is there a reason NOT to use them? If a classic class works fine, what >> > incentive is there to switch to new style classes? >> >> Perhaps classic classes will eventually disappear? > >It just means that the formerly "classic" syntax will define a >new-style class. Try to write code that works either way. > >It would be nice if a __future__ directive were added right now (if >it's not there already) that processes all class definitions as >new-style. Otherwise there's no easy way to test for compatibility. UIAM, it's not so bad: >>> class C: pass ... >>> type(C) <type 'classobj'> >>> class D(object): pass ... >>> type(D) <type 'type'> >>> __metaclass__ = type >>> class E: pass ... >>> type(E) <type 'type'> So I guess you can put __metaclass__ = type where you would have done the __future__ thing. If you want to do a special metaclass thing (even using a proper class ;-), you can override the global __metaclass__ >>> def MC(*a): print a; return type(*a) ... >>> class F: ... __metaclass__ = MC ... pass ... ('F', (), {'__module__': '__main__', '__metaclass__': <function MC at 0x02EE8D4C>}) Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list