开发者

Why does my function call not print out what it's supposed to? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhet开发者_如何学Corical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
class A:
    def __init__(self, blocking, b = None):
        self.blocking = blocking

    def printerthing(self):
        print "hi this is a test"        

a = A(True)
a.printerthing
print("5")


You're not actually calling the function, you're just accessing a reference to it (and then doing nothing with it). You probably want:

a.printerthing()


try a.printerthing()?

Each method call has to have a ()


print in python3.x is different from print in python2.x

#!/usr/local/bin/python3

class A:
    def __init__(self, blocking, b = None):
        self.blocking = blocking

    def printerthing(self):
        print("hi this is a test")      

a = A(True)
a.printerthing
print("5")

it prints "5".

Andy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜