[Tutor] Some questions about importlib

2018-10-21 Thread Quentin Agren
Hi, My name Quentin, and this is my first post to this list so please redirect me if this is not the proper audience. I have been studying the 'importlib' standard library package this past week, and although I find it very readable I am puzzled by some questions that I'd like to share. -

Re: [Tutor] Can tempfile.NamedTemporaryFile(delete=False) be used to create *permanent* uniquely named files?

2018-10-21 Thread Quentin Agren
Hi Robert, Far from being an expert, my two cents on this: - As I understand it, you should at least use the 'dir' parameter to NamedTemporaryFile, otherwise your files will be created in a '/tmp/'-like directory that may be wiped clean by the OS now and then. - I seems that the only

[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

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