[Tutor] code in a folder

Alan Gauld alan.gauld at btinternet.com
Tue Dec 26 12:56:54 CET 2006

"linda.s" <samrobertsmith at gmail.com> wrote

>I read an example code, with something like:
> from a.b import *
> I checked and found a is a folder name and b is python code in that
> folder. I typed the above code in the IDLE and no error was 
> reported.
> Why a.b works?

This is Python "package" notation.
You can make a folder of python modules into a package
by adding a file called __init__.py. The details are described



Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list