[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Oscar Benjamin
On Mon, 12 Apr 2021 at 21:27, Brendan Barnwell wrote: > > On 2021-04-12 03:13, Stéfane Fermigier wrote: > > The public API of a library is the one which is documented as > > such. > > > > Right, except that in practice: > > > > 1) Many useful libraries are not documented or properly docume

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Guido van Rossum
Wow, super helpful response. On Mon, Apr 12, 2021 at 1:26 PM Brendan Barnwell wrote: > On 2021-04-12 03:13, Stéfane Fermigier wrote: > > The public API of a library is the one which is documented as > > such. > > > > > > Right, except that in practice: > > > > 1) Many useful libraries ar

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Brendan Barnwell
On 2021-04-12 03:13, Stéfane Fermigier wrote: The public API of a library is the one which is documented as such. Right, except that in practice: 1) Many useful libraries are not documented or properly documented. Then they're buggy. I'm not convinced by the argument that "in prac

[Python-ideas] Re: Revive: PEP 396 -- Module Version Numbers ?

2021-04-12 Thread Paul Moore
On Mon, 12 Apr 2021 at 19:52, Christopher Barker wrote: > > Over the years, I've seen __version__ used very broadly but not *quite* in > all packages. I've always known it was a convention, not a requirement. But > it turns out it's not even a "official" convention. > > But it really would be ni

[Python-ideas] Re: Revive: PEP 396 -- Module Version Numbers ?

2021-04-12 Thread Thomas Grainger
I prefer to use importlib.metadata.version("dist-name") On Mon, 12 Apr 2021, 19:51 Christopher Barker, wrote: > Over the years, I've seen __version__ used very broadly but not *quite* in > all packages. I've always known it was a convention, not a requirement. But > it turns out it's not even a

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Neil Girdhar
This is a great discussion. However, there's one issue that seems to be getting lost. Consider this library structure: test/lemon test/lemon/__init__.py test/module.py where test/module.py is: __all__ = ['lemon'] def lemon(): pass and test/__init__.py is: from .module import * from .lemo

[Python-ideas] Revive: PEP 396 -- Module Version Numbers ?

2021-04-12 Thread Christopher Barker
Over the years, I've seen __version__ used very broadly but not *quite* in all packages. I've always known it was a convention, not a requirement. But it turns out it's not even a "official" convention. But it really would be nice if there was a consistent way that I could count on to get the vers

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Joseph Martinot-Lagarde
M.-A. Lemburg wrote: > The public API of a library is the one which is documented as > such. That's really all there is to it. Documentation is written > explicitly by the author of a package and languages provides > a lot more nuances than using some programmatic mechanism. I use __all__ with sphi

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Paul Moore
On Mon, 12 Apr 2021 at 11:41, M.-A. Lemburg wrote: > > Right, except that in practice: > > > > 1) Many useful libraries are not documented or properly documented. > > In those cases, I'd argue that such libraries then do not really care > for a specific public API either :-) > > > 2) People don't

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread M.-A. Lemburg
On 12.04.2021 12:13, Stéfane Fermigier wrote: > > > On Mon, Apr 12, 2021 at 11:39 AM M.-A. Lemburg > wrote: > > I don't think that trying to do this programmatically via some > kind of language construct is a good approach. > > > It's not the only approach, but

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Stéfane Fermigier
On Mon, Apr 12, 2021 at 11:39 AM M.-A. Lemburg wrote: > I don't think that trying to do this programmatically via some > kind of language construct is a good approach. > It's not the only approach, but I argue that it's useful. Two use cases: - IDE's that will nudge the developer towards import

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread M.-A. Lemburg
I don't think that trying to do this programmatically via some kind of language construct is a good approach. The public API of a library is the one which is documented as such. That's really all there is to it. Documentation is written explicitly by the author of a package and languages provides

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Stéfane Fermigier
On Sun, Apr 11, 2021 at 2:07 PM Oscar Benjamin wrote: > On Sun, 11 Apr 2021 at 10:25, Stéfane Fermigier wrote: > > > 2) What's a "public API" ? A particular library can have an internal API > (with regular public functions and methods, etc,) but only willingly expose > a subset of this API to it