[Tutor] Adding custom modules to the module index?

Kent Johnson kent_johnson at skillsoft.com
Sat Aug 7 19:35:04 CEST 2004


One easy way to do this is to put your module in the directory 
Lib/site-packages in your Python distribution. Anything in this directory 
will be available to import in all your programs.

Kent

At 11:20 PM 8/6/2004 +0200, Ole Jensen wrote:
>How do you add custom modules so that you are able to import them
>directly from python?
>
>E.g. I want to import MyNewModule, and want to avoid the following:
>
> >>> Import MyNewModule
>
>Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in -toplevel-
>     import MyNewModule
>ImportError: No module named MyNewModule
>
>I've read that its possible to add your own modules so they can be
>imported from IDLE like above, I just cannot remember how!? I've tried
>searching through google and python.org but I've lacked a key search
>word so I hope someone here can help me.
>
>-------
>
>My question is derived from wanting to try out the Zope DataBase (ZODB)
>as it says in the documentation
>(http://zope.org/Documentation/Articles/ZODB1):
>
>[quote]
>After installing ZODB, you can start to experiment with it right from
>the Python command line interpreter. For example, try the following
>python code in your interpreter::
> >>> from ZODB import FileStorage, DB >>> storage =
>FileStorage.FileStorage(mydatabase.fs) >>> db = DB(storage) >>>
>connection = db.open() >>> root = connection.root()
>[/quote]
>
>I have just installed Zope and I read the above as if I straight away
>should be able to play around with ZODB within IDLE, please correct me
>if I am way of base...
>
>TIA
>Ole Jensen
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list