>
> Mangling __import__ temporarily might work, sounds like a hack I would
>> prefer to avoid. And theoretically __init__.py can include other heavy code.
>> And you could break stuff if __init__.py assumes that the imports work in a
>> way that returning a mock object breaks.
>>
>
> Definitely not pretty. But can you come up with an example of how it would
> be broken? I think most such examples would be pretty contrived and not
> something that's likely to be written in real life.
>

Even something as simple as this would break (if not in the import
statement, then later):
from some_package.some_module import some_thing


>
>> Do you have a really good reason not to make the writer of a simpack
>> responsible for making __init__.py quick to import? Then you can optimize
>> only if a real need arises.
>>
>
> I personally believe that `__init__.py` should import important stuff from
> the package, and not only in simpacks but in general in Python packages.
>

Then perhaps such metadata shouldn't be kept in __init__.py in the first
place?

- Tal
_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il

לענות