On Tue, Jun 01, 2021 at 10:17:32PM +1000, Chris Angelico wrote:
> My understanding is that it would attempt to invoke
> __detonation_call__ (err, I mean, __decoration_call__, but just think
> how awesome the other would be) first, and if it can't find it, it
> falls back on regular __call__. That would parallel how most other
> things are done - repr falling back to str, iadd falling back to add,
> etc.
Sure, but the analogy is more like trying repr first to produce a
string, and if that doesn't work, trying iter to produce a list.
Function/class decoration shares little with "variable decoration"
except the name and (proposed) use of the @ syntax. It seems to me that
they are only the most loosely related concepts.
Ricky's proposal to use a new dunder magnifies the differences and
obfuscates the similarities.
> That said, I still don't like the idea of decorating a bare name. A
> magic "assignment target" token that translates into the string form
> of the thing being assigned to is far more useful and far less
> magical.
Obviously I agree, given that I proposed a special @@ symbol to do that
however Stéfane's real-world example of chaining variable decorators has
forced me to take that idea seriously.
@acl(READ, WRITE)
@constraint(10 < _ < 100)
@not_null
@indexed
@depends_on(whatever)
@inject
@...
first_name: str
https://mail.python.org/archives/list/[email protected]/message/DCKFMWRKUQ5G2GDN6Z2DLJRKQ4LDVRIQ/
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/5XQOIVW7XYT7QLHSC5BWW3LJ4GIPEWHX/
Code of Conduct: http://python.org/psf/codeofconduct/