Is there any way to do this without using '__init__'?

Posted by zjm1126 on Stack Overflow See other posts from Stack Overflow or by zjm1126
Published on 2010-05-29T08:35:39Z Indexed on 2010/05/29 12:02 UTC
Read the original article Hit count: 160

Filed under:
class a(object):
    c=b()# how to call the b method 
    d=4
    def __init__(self):
        print self.c
    def b(self):
        return self.d+1

a()

how to call the 'b' method not in the __init__

thanks

the error is :

Traceback (most recent call last):
  File "D:\zjm_code\a.py", line 12, in <module>
    class a(object):
  File "D:\zjm_code\a.py", line 13, in a
    c=b()# how to call the b method 
NameError: name 'b' is not defined

© Stack Overflow or respective owner

Related posts about python