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

Rob Cliffe rob.cliffe at btinternet.com
Thu Jun 9 06:30:46 EDT 2016


On 09/06/2016 03:29, MRAB wrote:
> On 2016-06-09 00:28, Barry Warsaw wrote:
>> On Jun 08, 2016, at 10:57 PM, Michael Selik wrote:
>>
>>> 3. @public for constants (as per Barry's email)
>>>
>>> I don't know what that last one was referring to. Do you mind 
>>> clarifying,
>>> Barry (or anyone else)?
>>
>> Sure!
>>
>> I propose that it's difficult to keep __all__ up to date. Witness the
>> plethora of bugs open on similar issues in the stdlib. Furthermore, the
>> definition of __all__ is usually far removed from the object it 
>> names.  And
>> it's not obvious when looking at the object whether it is intended to be
>> exported or not.
>>
>> @public solves these problems and I contend that its meaning is pretty
>> obvious, given that (unknown to me at the time) there have been at 
>> least two
>> other independent inventions of nearly exactly the same decorator.
>>
> [snip]
>
> A workaround is to use a comment:
>
> #@public
> SEVEN = 7
>
> and a script that parses the file and updates the __all__.
>
Another workaround which I use is to initialise __all__ to [] (or 
whatever), and then write
__all__.extend([ ..... ])
to add some thing(s) I've just defined.
Rob Cliffe


More information about the Python-ideas mailing list