469,314 Members | 2,144 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,314 developers. It's quick & easy.

Include File?

Hi
i am a totally python newcomer. Can i use
include files within python?

(like for example: include <xxx.py>)

Thanks for help in advance
Werner Hofer
Jul 18 '05 #1
4 46337
Whofer wrote:
i am a totally python newcomer. Can i use
include files within python?

(like for example: include <xxx.py>)

The python equivalent is

import xxx

#use it, assuming the doSomething() function is defined in module xxx:
xxx.doSomething()

If you already know a programming language, the tutorial that comes with the
python distribution is a good starting point to learn the language.
Good luck!

Peter
Jul 18 '05 #2
Whofer wrote:

i am a totally python newcomer. Can i use
include files within python?

(like for example: include <xxx.py>)


Have you gone through the several tutorials and web pages for newcomers?

Questions like this should be adequately covered in them, so it would
be surprising if you've read them yet still don't know about "import".

-Peter
Jul 18 '05 #3
Cam
I am not so new and I still dont know if its possible.
I 2nd that question.

Whofer wrote:
Hi
i am a totally python newcomer. Can i use
include files within python?

(like for example: include <xxx.py>)

Thanks for help in advance
Werner Hofer


Jul 18 '05 #4
Cam <no**********************@pacific.net.au> writes:
I am not so new and I still dont know if its possible.
I 2nd that question.

Whofer wrote:
Hi
i am a totally python newcomer. Can i use
include files within python?
(like for example: include <xxx.py>)
Thanks for help in advance
Werner Hofer


There is no raw-file include (as in C's cpp) in the Python language.
(Of course, you could use #include and run cpp on the file
before passing it to Python.)

The Pythonic way to do this is "import". Unlike cpp, the imported
file must be a valid python module in its own right, though it can be
pretty simplistic. E.g., you could just define a list.

--
ha************@boeing.com
6-6M31 Knowledge Management
Phone: (425) 342-5601
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by middletree | last post: by
6 posts views Thread by qaz | last post: by
10 posts views Thread by Toke H?iland-J?rgensen | last post: by
10 posts views Thread by Raheem | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.