<div id="RTEContent">Thank you for the suggestion!<br><br><b><i>bruno at modulix <onurb@xiludom.gro></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">  limodou wrote:<br>> On 2/10/06, john peter <neuzhoundxx @yahoo.com=""> wrote:<br>(snip)<br><br>>> what do i have to do if i want my application code to have<br>>>read-only<br>>> attributes?<br>>><br>> I think you may consider property() built-in function:<br>> <br>> property( [fget[, fset[, fdel[, doc]]]])<br>> <br>> Return a property attribute for new-style classes (classes that derive<br>> from object).<br>> fget is a function<br><br>s/function/callable/<br><br>> for getting an attribute value, likewise fset is a<br>> function for setting, and fdel a function for del'ing, an attribute.<br>> Typical use is to define a managed attribute x:<br>> <br>> <br>> class C(object):<br>>    
 def __init__(self): self.__x = None<br>>     def getx(self): return self.__x<br>>     def setx(self, value): self.__x = value<br>>     def delx(self): del self.__x<br>>     x = property(getx, setx, delx, "I'm the 'x' property.")<br><br>Note that you don't need to define all three accessors. For a<br>'read-only' attribute, just define the getter:<br><br>class ReadOnly(object):<br>   def __init__(self, x):<br>      self._x = x<br>   x = property(fget=lambda self: self._x)<br><br>-- <br>bruno desthuilliers<br>python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for<br>p in 'onurb@xiludom.gro'.split('@')])"<br>-- <br>http://mail.python.org/mailman/listinfo/python-list<br></neuzhoundxx></blockquote><br></div><p>
                <hr size=1> Yahoo! Mail<br> 
<a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=38867/*http://photomail.mail.yahoo.com">Use Photomail</a> to share photos without annoying attachments.