09.12.20 22:39, Steven D'Aprano пише:
> On Wed, Dec 09, 2020 at 01:56:01PM +0200, Serhiy Storchaka wrote:
>
>> Thank you for good explanation of the problem.
>
> I'm sorry Serhiy, I disagree that this has been a "good explanation of
> the problem".
>
> Gregory has not identified any actual bugs caused by this. The only
> problem he has identified is that doing this will lead to two separate
> module objects from the same file, but as MAL points out, people can do
> this intentionally. Gregory hasn't identified any cases where people are
> doing this accidentally and having bugs in their code because of that.
> He just assumes that they are.
Maybe it is just me, because I read the original issue. But Gregory's
message looks to me well organized and answering questions that were
asked before and possible new questions.
Here is an example. File "foo/__init__.py" contains "class A: pass".
>>> from foo.__init__ import A
>>> import foo
>>> isinstance(A(), foo.A)
False
And this happens not only with classes. Modules foo and foo.__init__ has
similar content, but their values are not the same. Some values can be
identical, some are identical on some Python implementations and
non-identical on others, some are equal but non-identical, some are not
even equal.
> Gregory has still not been 100% clear that he is only talking about
> package __init__.py files. I am pretty sure that is what he means, but
> the only precise statement he has made is the code
>
> '__init__' in fullname.split('.')
>
> but that will effect non-package files:
>
> __init__.py # not a package, not a special name
>
> and also packages with unusual but legal names:
>
> package/subpackage/__init__/things/stuff.py
Since __init__ is a special name and directory __init__ conflicts with
file __init__.py, I do not think this is good idea. I am not even sure
that it works. I do not think this is necessary, but just for the case
it may be better to forbid intermediate __init__ components as well. But
it depends on the implementation. What will look more natural.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/CFONEBYRSBD746B3D2YGUATPSXBUZUQI/
Code of Conduct: http://python.org/psf/codeofconduct/