/usr/share/pyshared/rwproperty-1.0.egg-info/PKG-INFO is in python-rwproperty 1.0-2ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | Metadata-Version: 1.1
Name: rwproperty
Version: 1.0
Summary: Read & write properties
Home-page: http://www.z3lab.org/sections/blogs/philipp-weitershausen/2006_05_29_pycon-06-lightning-talk
Author: Philipp von Weitershausen
Author-email: grok-dev@zope.org
License: ZPL
Download-URL: http://codespeak.net/svn/user/philikon/rwproperty#egg=rwproperty-dev
Description: Read & write properties
========================
:Author: Philipp von Weitershausen
:Email: philikon@philikon.de
:License: Zope Public License, v2.1
Motivation
----------
Using method decorators and descriptors like ``property``, we can
easily create computed attributes:
>>> class JamesBrown(object):
... @property
... def feel(self):
... return self._feel
An attribute like this cannot be written, though. You would have to
do something like this:
>>> class JamesBrown(object):
... def _getFeel(self):
... return self._feel
... def _setFeel(self, feel):
... self._feel = feel
... feel = property(_getFeel, _setFeel)
The problem with this approach is that it leaves the getter and setter
sitting around in the class namespace. It also lacks the compact
spelling of a decorator solution. To cope with that, some people like
to write:
>>> class JamesBrown(object):
... @apply
... def feel():
... def get(self):
... return self._feel
... def set(self, feel):
... self._feel = feel
... return property(get, set)
This spelling feels rather cumbersome, apart from the fact that
``apply`` is `going to go away`_ in Python 3000.
.. _going to go away: http://www.python.org/peps/pep-3000.html#id24
Goal
----
There should be a way to declare a read & write property and still use
the compact and easy decorator spelling. The read & write properties
should be as easy to use as the read-only property. We explicitly
don't want that immediately called function that really just helps us
name the attribute and create a local scope for the getter and setter.
Read & write property
---------------------
Read & write properties work like regular properties. You simply
define a method and then apply a decorator, except that you now don't
use ``@property`` but ``@getproperty`` to mark the getter and
``@setproperty`` to mark the setter:
>>> from rwproperty import getproperty, setproperty
>>> class JamesBrown(object):
... @getproperty
... def feel(self):
... return self._feel
... @setproperty
... def feel(self, feel):
... self._feel = feel
>>> i = JamesBrown()
>>> i.feel
Traceback (most recent call last):
...
AttributeError: 'JamesBrown' object has no attribute '_feel'
>>> i.feel = "good"
>>> i.feel
'good'
The order in which getters and setters are declared doesn't matter:
>>> from rwproperty import getproperty, setproperty
>>> class JamesBrown(object):
... @setproperty
... def feel(self, feel):
... self._feel = feel
... @getproperty
... def feel(self):
... return self._feel
>>> i = JamesBrown()
>>> i.feel = "good"
>>> i.feel
'good'
Of course, deleters are also possible:
>>> from rwproperty import delproperty
>>> class JamesBrown(object):
... @setproperty
... def feel(self, feel):
... self._feel = feel
... @getproperty
... def feel(self):
... return self._feel
... @delproperty
... def feel(self):
... del self._feel
>>> i = JamesBrown()
>>> i.feel = "good"
>>> del i.feel
>>> i.feel
Traceback (most recent call last):
...
AttributeError: 'JamesBrown' object has no attribute '_feel'
Edge cases
----------
There might be a case where you're using a flavour of read & write
properties and already have a non-property attribute of the same name
defined:
>>> class JamesBrown(object):
... feel = "good"
... @getproperty
... def feel(self):
... return "so good"
...
Traceback (most recent call last):
...
TypeError: read & write properties cannot be mixed with other attributes except regular property objects.
Platform: UNKNOWN
|