[Tutor] does python have something like "#include" in C?

Wayne srilyk at gmail.com
Mon Jun 29 17:21:19 CEST 2009


On Mon, Jun 29, 2009 at 10:03 AM, Robert Lummis <robert.lummis at gmail.com>wrote:

> ... or any pre-processing at all?
>
> I'm looking for a way to get boiler plate code into the main program
> file. Of course I could copy and paste it with an editor but I was
> hoping for something more pythonic. I know about import but that's not
> the same.
>

actually import is precisely the same.

 wayne at x61:test$ vi import1.py
wayne at x61:test$ vi import2.py
wayne at x61:test$ python import1.py
Imported

The contents of import1?

import import2

The contents of import2?

print "Imported"

You can define functions, classes, etc.

you call them as whatever.function(), unless you say

from module import * - then it willl import everything into the namespace of
your original file.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090629/91793484/attachment-0001.htm>


More information about the Tutor mailing list