Properties for several keywords

Kless jonas.esp at googlemail.com
Sun Jun 7 23:33:16 CEST 2009


On 7 jun, 11:45, Kless <jonas.... at googlemail.com> wrote:
> I've to write properties for several keywords with the same code, it
> only changes the name of each property:
>
> -----------------------------
> @property
>    def foo(self):
>       return self._foo
>
> @foo.setter
>    def foo(self, txt):
>       self._foo = self._any_function(txt)
>
> # ----------------
>
> @property
> def bar(self):
>    return self._bar
>
> @bar.setter
> def bar(self, txt):
>    self._bar = self._any_function(txt)
> -----------------------------
>
> Is possible to simplify it?

Please, is there any solution for this problem?



More information about the Python-list mailing list