properties - Python property -


The output given to the following code seems to be a bit confusing, why "gets in base" is printed only once? And why not "set in base" printed exactly? Actual recovery / setting works fine though. What am I missing?

  Category base: def __init __ (self): self.s = "baseStr" def getstr (self): print "get in base" returns self.s def setstr (self, s ): Printed "Base in Set" self.s = s str = property (getstr, setstr) b = base () print b.str b.str = "foo" print b.str  
< P> Output:

  Find the Base Base FU  

You have to use the qualities to work correctly. To do this, get your class from object :

  class base: ...  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -