[Python-ideas] Quick idea: defining variables from functions that take the variable name

Barry Warsaw barry at python.org
Mon Jun 6 18:32:21 EDT 2016


On Jun 01, 2016, at 03:53 PM, M.-A. Lemburg wrote:

>This could be done via a decorator:
>
>    @recordbinding
>    x = obj
>
>to result in the compiler generating the following code:
>
>    x = obj
>    obj.recordbinding('x', 2)

I like the idea of using a decorator because it's familiar syntax and we all
already (think we) know what it means.  However, in this case, wouldn't

    @recordbinding
    x = obj

translate to

    x = obj
    recordbinding(x)

?

The way you've written it, obj must be a type that implements the
recordbinding method, but that's not what I'd expect.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160606/b9dc99c7/attachment.sig>


More information about the Python-ideas mailing list