Why does my function call not print out what it's supposed to? [closed]
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
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论