subclass of object

Steve Holden steve at holdenweb.com
Fri Apr 2 08:19:09 EDT 2010


Alf P. Steinbach wrote:
> * Jason Friedman:
>> Hi, what is the difference between:
>>
>> def MyClass(object):
>>     pass
>>
>> and
>>
>> def MyClass():
>>     pass
> 
> If you really meant 'def', then the first is a routine taking one
> argument, and the second is a routine of no arguments.
> 
> If you meant 'class' instead of 'def', then it depends on the Python
> version.
> 
> In Py2 the first then defines a new-style class, while the second
> defines an old-style class. E.g. you can see some difference by checking
> with 'isinstance'. In Py3 there's no difference.
> 
Interesting. I actually read "class"  for "def" and replied accordingly.

As can plainly be seen ...

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list