Message266319
>>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. |
|
Date |
User |
Action |
Args |
2016-05-25 07:56:17 | leewz | set | recipients:
+ leewz, barry, rhettinger, r.david.murray, ethan.furman, berker.peksag, martin.panter, eryksun, jayvdb |
2016-05-25 07:56:17 | leewz | set | messageid: <1464162977.24.0.437491590252.issue26632@psf.upfronthosting.co.za> |
2016-05-25 07:56:17 | leewz | link | issue26632 messages |
2016-05-25 07:56:16 | leewz | create | |
|