[Tutor] Module (.py file) that behaves like package

2018-10-29 Thread Quentin Agren
Hi, By playing around with importlib I noticed that if you define `__path__ = [os.path.dirname(__file__)]` in a module named spam.py, then you could `import spam.spam.spam` or `from spam import spam`. In other words, spam.py behaves like a package although its loader, if asked, tells that it is no

Re: [Tutor] Module (.py file) that behaves like package

2018-10-29 Thread Alan Gauld via Tutor
On 29/10/2018 14:10, Quentin Agren wrote: > ... (Maybe I should just get out more...) That depends on whether you can foresee a use for importlib in your code. If so then getting to know it isn't a bad thing. If not, do you really want to be looking back on your 60th birthday thinking "Did I real

Re: [Tutor] Module (.py file) that behaves like package

2018-10-29 Thread Quentin Agren
Hi Alan, > That depends on whether you can foresee a use for importlib in > your code. Slightly disagreeing here. I think reading importlib source is a great way of understanding how the python import system works (if you don't want to read C, that is). I think a learnt a lot and it helped me