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

asp.net - Change the driver in the connection string to a data source in VB.Net -

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -