Please have a look at this:
class Car:
def __init__(self, bid_code):
self.__bid = bid_code
def doit(self, cry):
self.bid_it = cry
def show_bid(self):
print self.__bid
def show_it(self):
print self.bid_it
a = Car("ok")
a.show_bid()
a.doit("good")
a.show_it()
What is the scope of bid_it here? I thought it was a local variable, because it is inside a def block. How is it possible that I can call it outside the function? I haven't declared that bid_it is global.
Thanks
bid_codeis used is in the constructor, where it is the parameter. In all other case the property is accessed. Properties are not "scoped" as variables, although they run through a resolution chain. Neither properties nor variables are objects -- they can only contain/refer to objects.