[Python-ideas] Decorators for variables

Matthias welp boekewurm at gmail.com
Sun Apr 3 02:53:10 EDT 2016


> > var = property(setter, getter, deleter, docs)
> > var = 20
>
> Can you explain - or, preferably, demonstrate - the difference you're
> talking about here?

Sorry, that was untested code. My expectations of class definitions was
wrong, as it does not actually change behaviour inside it's own scope. I
thought that when you are defining a class, that when you assign a property
value to an attribute, that the attribute 'name value' will directly change
it's behaviour to include the descriptor properties of the property object
assigned. My mistake.

On 3 April 2016 at 08:32, Chris Angelico <rosuav at gmail.com> wrote:

> On Sun, Apr 3, 2016 at 4:05 PM, Matthias welp <boekewurm at gmail.com> wrote:
> > While keeping the '.__dict__' override method open, the way things work
> > currently won't change that much, but it will make the assignment of
> > attributes or variables with descriptor properties a lot more intuitive,
> as
> > you do not set a *name* to a variable and then can undo that just a while
> > later:
> >
> > var = property(setter, getter, deleter, docs)
> > var = 20
> >
> > currently changes behaviour depending on what kind of scope it is
> located in
> > (class description, any other scope), while decorators (for functions at
> > least) work in every scope I can think of. I think that is strange, and
> that
> > it should just be the same everywhere.
>
> Can you explain - or, preferably, demonstrate - the difference you're
> talking about here?
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160403/bcbd08ec/attachment.html>


More information about the Python-ideas mailing list