出现了问题,不知道如何解决,望大神帮忙解决一下
class Programmer(object):
def __new__(cls, *args, **kwargs):
print 'call __new__ method'
print args
print super(Programmer,cls).__new__(cls, *args, **kwargs)
def __init__(self,name,age):
print 'call __init__ method'
self.name = name
self.age = age
if __name__ == '__main__':
programmer = Programmer('Albert',25)
print programmer.__dict__
运行结果:
"C:\Program Files\Anaconda2\python.exe" C:/Users/Administrator/PycharmProjects/untitled/classlearning4-2.py
Traceback (most recent call last):
call __new__ method
('Albert', 25)
<__main__.Programmer object at 0x00000000022F2C50>
File "C:/Users/Administrator/PycharmProjects/untitled/classlearning4-2.py", line 17, in <module>
print programmer.__dict__
AttributeError: 'NoneType' object has no attribute '__dict__'