#-.-Coding:utf-8-.-
# __author__ = ' Zhengtong '
class Person: ' "
without Object" ""
name = " Zhengtong "
class Animal (object):" "
with Object
" ""
name = "Chonghong"
if __name__ = = "__ Main__ ':
x = person ()
print ' person ', dir (x)
y = Animal ()
print "Animal", dir (y)
Run results
person [' __doc__ ', ' __module__ ', ' name ']
Animal [' __class__ ', ' __delattr__ ', ' __dict__ ', ' __doc__ ', ' __format__ ', ' __getattribute__ ',
' __hash__ ', ' __init__ ', ' __module__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ',
' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' __weakref__ ', ' name '
The person class is clearly able to see the difference, not inheriting object, only Doc, module, and its own defined name variable, which means that the namespace of this class has only three objects to manipulate.
The animal class inherits object objects and has many operable objects, which are advanced in the class.
These advanced features are largely useless for students who don't know much about python, but for those who want to write frameworks or write large projects, these features are more useful, such as tornado, where the exception capture is useful to class to locate the name of the class. There is also a high degree of flexibility to pass the parameters of the time to use Dict to complete.
Finally, the article is based on the Python version 2.7.10, which actually has the default in Python 3 for you to load object (even if you don't write object).
Source: https://blog.csdn.net/w571523631/article/details/55099385