Franklin? Lee added the comment:

>>If @public were only to be used as a decorator, it would not be possible to
>>have `public` called on a function outside of its definition. But someone
>>might call `public(some_decorator(some_function))`.
>
>Do you mean, they'd call this is some module other than the one some_function
>was defined in?  I don't know that this is a use case we even want to support.

I mean they'd define their own function as a wrapped version of another 
function.


>That's true in a sense.  It doesn't change the decorated thing at all.  I
>think it's important to keep in mind that @public isn't the only way to add to
>__all__.

I mean more in that it acts in the scope of its caller, rather than its 
definition.


>You should get something like:
>
>AttributeError: 'tuple' object has no attribute 'append'
>
>which seems pretty obvious.

I don't think the C version shows a traceback, so it won't be clear that you're 
trying to assign to `__all__`.

When I rewrote `public` from memory, I wrote it something like this:
        try:
            dunder_all.append(name)
        except TypeError:
            module.__all__ = [*dunder_all, name]


>Well, consenting adults and all.  I'm not sure we need to protect ourselves so
>strictly against people who don't read the docs and don't understand Python
>(i.e. random cargo-culters).

Python is a popular learning language, and many will be students who haven't 
yet trained to reflexively look up docs. I saw the lack of such habits in 
Python's IRC channel.

"Consenting adults", I feel, is a reason to grant power: don't stop people from 
doing something they might need to do. But @public on a class method is just an 
error.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26632>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to