OR,
class Foo(object):

    def __init__(self):
        self._bar = ""
    @property

    def bar(self):
        return self._bar
    @bar.setter

    def bar(self, val):
        self._bar = val.upper()
 
f = Foo()
f.bar = "eu"
print( f.bar)
-> 'EU' 



>class Foo(object):
>    def __init__(self):
>        self._bar = ""
>    def _getBar(self):
>        return self._bar 
>    def _setBar(self, val):
>        self._bar = val.upper()
>    bar = property(_getBar, _setBar)
>
>f = Foo()
>f.bar = "ed"
>print f.bar
>-> 'ED'
>
>    The point being that for the vast majority of object attributes, no such 
>manipulation is needed, so the code is simple. When more complex behavior is 
>needed, then and *only* then do you need to write more complex code.
>
>
>-- Ed Leafe
>
>
>
>
>_______________________________________________
>Post Messages to: [email protected]
>Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
>OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
>Searchable Archive: http://leafe.com/archives/search/profox
>This message: 
>http://leafe.com/archives/byMID/profox/[email protected]
>** All postings, unless explicitly stated otherwise, are the opinions of the 
>author, and do not constitute legal or medical advice. This statement is added 
>to the messages for those lawyers who are too stupid to see the obvious.
>
>
>

--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to