should I put old or new style classes in my book?

Eduardo O. Padoan eduardo.padoan at gmail.com
Fri May 30 08:16:14 EDT 2008


On Thu, May 29, 2008 at 3:06 PM, Jason <tenax.raccoon at gmail.com> wrote:
> I've got Python 3.0 alpha 2.  In this version, it looks like you can
> define classes in either the old style or new style.  (I snipped the
> top line a bit in the following example):

Wrong. Py3k Classes are always new-style. They subclass object
implicitly when no superclass is given.

> Python 3.0a2 (r30a2:59405M, Dec  7 2007, 15:23:28
> Type "help", "copyright", "credits" or "license"
>>>> class one(object): pass
> ...
>>>> class two: pass
> ...
>>>> two
> <class '__main__.two'>
>>>> one
> <class '__main__.one'>
>>>> type(one)
> <type 'type'>
>>>> type(two)
> <type 'type'>
>>>>

Both classes are new style.


-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt



More information about the Python-list mailing list