By default, an object is considered true unless its class defines either a __bool__() method that returns False or a __len__() method that returns zero, when called with the object. Here are most of the built-in objects considered false: constants de…
Python文档中有一段话: Remember that arguments are passed by assignment in Python. Since assignment just creates references to objects, there’s no alias between an argument name in the caller and callee, and so no call-by-reference per se. 我们常说参数的传递分为按值传递与按引…
class MyTest: myname = 'peter' # add a instance attribute def __init__(self, name): self.name = name # class access class attribute def sayhello(self): print "say hello to %s" % MyTest.myname # instance can access class attri…