[Python-ideas] C# style properties

George Sakkis george.sakkis at gmail.com
Thu Jul 12 19:20:09 CEST 2007


On 7/12/07, Steven Bethard <steven.bethard at gmail.com> wrote:

> On 7/12/07, Christian Heimes <lists at cheimes.de> wrote:
> > What do you think about this syntax?
> >
> > class EasyExample:
> >     _a = 0.0
> >     property a:
> >         """doc string
> >         """
> >         def get(self) -> float:
> >             return self._a
> >         def set(self, value):
> >             self._a = float(value)
> >         def delete(self):
> >             del self._a
>
> I'm pretty sure Guido's said before that he doesn't like the
> get/set/del methods being indented more than other instance methods
> would be. If you really like this style, you can get something like it
> today using inner classes:
>
>     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442418

Or decorators: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698


George

-- 
"If I have been able to see further, it was only because I stood on
the shoulders of million monkeys."



More information about the Python-ideas mailing list