[Tutor] use my own code

Evert Rol evert.rol at gmail.com
Sun Nov 25 18:49:40 CET 2007


> ok, i can import them.
>
> how do I use them though?

That's also in the tutorial; if there are variables (constants)  
instead of functions in your module, it works just the same.


> > I have some .py files that have things I need to use,  sometimes
> > it's the functions and sometimes it's the whole .py (they have no
> > functions)
> >
> > how do I use them in my other .py codes?
>
> Import them at the top of your other .py file(s):
>
> import <yourfile>
>
> (without the .py extension).
> If they're in the current directory, you're fine. Otherwise you may
> need to set the PYTHONPATH variable.
> See chapter 6 in the Python tutorial, especially section 6.1.1:
> http://docs.python.org/tut/node8.html#SECTION008110000000000000000
>
>  Evert
>
>



More information about the Tutor mailing list