class definition syntax

H

harryos

hi
i have seen some class definitions like

class MyClass(object):
def __init__(self):
....

what does the object keyword inside the braces in MyClass() mean?
Has it got any significance?

thanks in advance
harry
 
D

Diez B. Roggisch

harryos said:
hi
i have seen some class definitions like

class MyClass(object):
def __init__(self):
....

what does the object keyword inside the braces in MyClass() mean?
Has it got any significance?

It indicates a so-called new-style-class. The new style classes have been
available since python2.2:

http://docs.python.org/ref/node33.html

Diez
 
K

Ken Starks

harryos said:
hi
i have seen some class definitions like

class MyClass(object):
def __init__(self):
....

what does the object keyword inside the braces in MyClass() mean?
Has it got any significance?

thanks in advance
harry

It is a syntax used for 'new type' classes, not so new any more.

If you google that phrase, you get many references.

Here is a tutorial dating back to 2005.
http://www.geocities.com/foetsch/python/new_style_classes.htm
 
B

Bruno Desthuilliers

harryos a écrit :
hi
i have seen some class definitions like

class MyClass(object):
def __init__(self):
....

what does the object keyword

It's not a keyword.
inside the braces in MyClass() mean?

Answer is here:

http://docs.python.org/tut/node11.html#SECTION0011500000000000000000
http://docs.python.org/ref/class.html

Has it got any significance?

<ironic>
Nope, why ? It just look better that way...
</ironic>

Harry, this neswgroup is - as you may have noticed by now - very newbie
friendly. But this is not a reason for not reading *at least* the
FineManual's tutorial.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top