FearAndLoath.Us

Fear Computers. Loath Software. We are your Masters.

Sunday, February 3, 2008

Cleaner setters for attributes in python

Using a method for a read-only object attribute is very clean in python.

class foo:
    @property
    def name(self):
        return self._name

However, providing a setter method is somewhat ugly. Someone came up with an interesting workaround.

posted by admin at 5:01 pm  

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress