[Tutor] How does one construct a module for import?

Sydney Shall s.shall at virginmedia.com
Mon Jun 2 16:41:15 CEST 2014


Alan,
Please forgive me, but I am still unclear.
Do you mean that I must add a file called __ini__.py to my folder or do 
you mean that each file that I wish to import should have that statement 
[ __init__.py ] immediately after (I presume) my def statement?
If it must be a file, what is in this file?
With many thanks,
Sydney


On 02/06/2014 14:52, Alan Gauld wrote:
> On 02/06/14 13:21, Sydney Shall wrote:
>
>> I do not really understand what Steven is recommending below.
>> Is it an init statement in a file or is it an independent file.
>
> It is an independent file (which can be empty) whose existence
> indicates to python that a folder is a package.
>
> Thus if you have a folder abc which contains files a,b and c.
> Even if abc is in Python's import path you cannot
> import a,b or c unless there is an __init__.py
>
> HTH

-- 
Sydney Shall



More information about the Tutor mailing list