By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,941 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,941 IT Pros & Developers. It's quick & easy.

PyDev multiple source files?

P: n/a
Newbie questions on PyDev project setup. Things are going fine -
writing python code in eclipse/pydev and running them with various
imports etc, doing wxpython stuff blah, blah, blah. My .py code is in
a module, in a package, in a project. It runs fine.

Now I want to be able to break my single source file up into multiple
files to segregate functions, divide up with others, etc, but I don't
know how to configure it. I pulled one simple class definition out of
my single source file and created a new .py file with just that in
there. But now I'm stalled...

What is the equivalent of an 'include' statement. I assume there's
something I put into one .py file to say I'm using stuff in another
local .py file. I tried using "import" but it doesn't seem to work -
ie code doesn't know about the class in the other file.

Also, how about global vars that are needed across multiple .py files?
Where do I declare them to be understood in all the files that use
that global.

I suspect there is something I do in __init__.py - perhaps the
equivalent of 'include' statements in there with all my globals
stuffed in there too??? I'm lost here, but will continue to play
with it. Any hints appreciated. Surely all python developers don't
cram everything into one huge file (I hope).

Ross.
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On May 30, 2:10 pm, RossGK <ros...@gmail.comwrote:
Now I want to be able to break my single source file up into multiple
files to segregate functions, divide up with others, etc, but I don't
know how to configure it.
Found a reference that helped me out:

http://www.python.org/doc/2.1.3/tut/node8.html

The keys for me are that a) a file named junk.py is called a module (I
thought a module was a set of files within a package - nope just a
source file).

Import is the right thing for an 'include' action - but after you
import you need to hierarchically reference the contents of the
imported module. So if my junk.py 'module' contains a "def things",
then after I have done my "import junk" I refer to things as
junk.things

Global seem to have a scope of only their current module. So the
question that comes to mind is how to create a global global. Can I
stick it into __init_.py or something and have it available for the
whole package?
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.