On Apr 16, 10:40 am, Aaron Watters <[EMAIL PROTECTED]> wrote: > On Apr 16, 12:27 pm, Rhamphoryncus <[EMAIL PROTECTED]> wrote: > > > On Apr 16, 6:56 am, Aaron Watters <[EMAIL PROTECTED]> wrote: > > > > I don't get it. It ain't broke. Don't fix it. > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me.
>>> type(3) <type 'int'> >>> (3).__class__ Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'int' object has no attribute '__class__' >>> class Foo: pass ... >>> type(Foo()) <type 'instance'> >>> Foo().__class__ <class __main__.Foo at 0x811f47c> With new-style classes, (3).__class__ returns int and type(Foo()) returns Foo. Of course a lot of other aspects were redesigned at the same time, such as how attributes/methods are looked up. The consequence of that is we got descriptors. Seems like a fair trade to me. Another example of an incompatible change was this: >>> 2**32 Traceback (most recent call last): File "<stdin>", line 1, in ? OverflowError: integer exponentiation In recent versions of 2.x you get this instead: >>> 2**32 4294967296L Finally, 3.0 changes it to this: >>> 2**32 4294967296 Personally, I find all these changes to be a good thing. They make the language cleaner and more useful. The only reason to not make the changes is that old, crufty, unmaintained libraries & applications might depend on them somehow. If that's more important to you, what you really want is a language who's specs are frozen - much like C effectively is. I hope python doesn't become that for a long time yet, as there's too much it could do better. -- http://mail.python.org/mailman/listinfo/python-list