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

Oleg Broytman phd at phdru.name
Thu Jun 9 07:04:52 EDT 2016


On Thu, Jun 09, 2016 at 11:30:46AM +0100, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
> 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.

   @public is just a special syntax for that.

> Rob Cliffe

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-ideas mailing list