13

What is & lt; Bound method person.get_name of & lt; __ hand __. Object p...

 3 years ago
source link: https://www.codesd.com/item/what-is-bound-method-person-get-name-of-hand-object-person-to-0x02887790-mean.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What is & lt; Bound method person.get_name of & lt; __ hand __. Object person to 0x02887790 & gt; & Gt; mean

advertisements

Just wanted to know why I am getting this error in my program. kinda new to python and Stackoverflow and i saw a type of bound method error somewhere else but did not quite understand it.

class person(object):

    def get_name(self):

        self.name=raw_input("what is your name?")
        ans=raw_input("your name is %s right?" %self.name)

        while ans=="no":
            name=raw_input("sorry about that what is your name then?")
            ans="yes"
        else:
            print ("nice to have you %s !!" %self.name)

bob= person()
bob.get_name()

print bob.get_name


It's not an error; it's simply what bob.get_name looks like (that is, it's what you get when you print a method). You probably meant to print the return value of the method, for which you have to call it:

print bob.get_name()

(Note the ().)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK