[Tutor] Importing packages

Pacific Morrowind pacificmorrowind at gmail.com
Fri Jan 21 10:58:04 CET 2011


Hi;

On 21/01/2011 1:10 AM, arun kumar wrote:
> Hi,
>
> I'm trying to program with gdata
> (http://code.google.com/p/gdata-python-client/) using python
> library.I'm having problem in writing import statements.
>
> The source directory content is like this:
>
> atom(folder): this folder contains some files with the .py extension
> gdata (folder):this folder contains some folders and as well as some
> files with the .py extension. Also each of the folders contain a
> __init__.py file.
>
> I want to use the classes and functions of the gdata and its inner
> folders' classes and functions.
>
> please  tell me how write the import statements
Without knowing the exact names/format of those folders can't be 100% 
exact but you'd want to say something along the lines of

import gdata.example.funky
to import the module gdata/example/funky.py
or
import gdata.example2
to import the package gdata/example2 (__init__.py) - just a quick method 
to say the same thing as import gdata.example2.__init__ basically and 
logically is clear that that is the base fuctions/info etc. for that 
package (example2).
Pacific


More information about the Tutor mailing list