Hi,

I have a file named demo.py.The contents of the file are:

class a:
          name="swapna"
          def show(self):
                        print a.name
 
s=a()
s.show()

When I execute the file it gives me the following error:

"<bound method a.show of <__main__.a instance at 0x009D58C8>>"

Kindly advice on how to proceed with it.

I would use self to carry the variable name within the class. Also by convention class names start with an uppercase letter.

class A:
    name = "swapna"
    def show(self):
        print self.name
 
s = A()
s.show()

Swapana,
the code u have sent I typed as it is in the script and it worked without any error

Looks more like message from lint-filter, telling you to use self. Some of the commercial IDEs have filters built in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.