Re: Are all classes new-style classes in 2.4+?
- From: "Felipe Almeida Lessa" <felipe.lessa@xxxxxxxxx>
- Date: Sun, 31 Dec 2006 10:59:15 -0200
On 31 Dec 2006 03:57:04 -0800, Isaac Rodriguez
<isaac.rodriguez@xxxxxxxxxxx> wrote:
I am using Python 2.4, and I was wondering if by default, all
classes are assumed to be derived from "object".
This won't tell you advantages or disadvantages, but will show you
that the default still is the old-style:
.... passclass old:
....
<type 'instance'>type(old())
['__doc__', '__module__']dir(old())
.... pass
class new(object):
....
<class '__main__.new'>type(new())
['__class__', '__delattr__', '__dict__', '__doc__',dir(new())
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__']
In general, even if you don't understand the differences, it's better
to use new-style (they're new ;-). Anyway, see
http://effbot.org/pyref/new-style-and-classic-classes.htm for a little
more information.
--
Felipe.
.
- References:
- Are all classes new-style classes in 2.4+?
- From: Isaac Rodriguez
- Are all classes new-style classes in 2.4+?
- Prev by Date: Re: Question concerning this list [WebCrawler]
- Next by Date: A question about unicode() function
- Previous by thread: Re: Are all classes new-style classes in 2.4+?
- Next by thread: Re: Are all classes new-style classes in 2.4+?
- Index(es):