[Tutor] 'object' class

Dave Angel d at davea.name
Fri Oct 14 23:21:48 CEST 2011


On 10/14/2011 10:17 AM, Rafael Durán Castañeda wrote:
> 2011/10/14 Max S.<maxskywalker1 at gmail.com>
>
>> I have seen classes created with 'class Class_Name:' and 'class
>> Class_Name(object):'.  I'm using the latter, just in case it has some sort
>> of method that could be useful that I don't know about, but *are *there
>> any methods in the 'object' class?  And if so, what are they?
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>> This new style vs old style<http://wiki.python.org/moin/NewClassVsClassicClass>classes question, you can find a lot of information if you search about it.
Things not covered by that wiki page,

1) in Python 3.x, all classes are new-style, regardless of which syntax 
you use.

2) I believe super() is new to new-style classes.  In any case the 
documentation for it seem to assume new-style.

3) you could have answered your own question about methods in a 
particular class.  Just use 'dir'

 >>> dir(object)
['__class__', '__delattr__', '__doc__', '__format__', 
'__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__']
 >>>


-- 

DaveA



More information about the Tutor mailing list