[Python-ideas] Proposal for special name and qualname symbols

Eric V. Smith eric at trueblade.com
Wed Jun 8 21:30:24 EDT 2016


On 6/8/2016 7:58 PM, Ethan Furman wrote:
> On 06/08/2016 04:28 PM, Barry Warsaw wrote:
>> On Jun 08, 2016, at 10:57 PM, Michael Selik wrote:
>
>> The issue in this context is that @public as a decorator only works
>> for things
>> with an __name__, e.g. functions and classes.  There have been different
>> proposals to make it work for constants, and my approach supports calling
>> public() with keyword arguments, e.g.
>>
>> public(SEVEN=7)
>> public(a_bar=Bar())
>>
>> Admittedly this is rather un-Pythonic since it not only modifies the
>> module's
>> __all__ but it pokes a variable binding into the module globals.  It's
>> yucky
>> and I'd rather be able to do something like:
>>
>> @public
>> SEVEN = 7
>>
>> @public
>> a_bar = Bar()
>>
>> Thus the relevance to this thread.
>
> How would those examples look if we had the __LHS__ working?

Presumably:

SEVEN = public(__LHS__, 7)
a_bar = public(__LHS__, Bar())

Although this might be a different version of public (or not!).

Eric.




More information about the Python-ideas mailing list