[Tutor] Importing multiple files as a single module?
Ryan Davis
ryan at acceleration.net
Fri Jan 21 19:46:13 CET 2005
I'm having the same problem, and am eager to hear the responses. As far as a "real" IDE, emacs works pretty well, and check out
Komodo, the ActiveState IDE:
http://www.activestate.com/Products/Komodo/
Thanks,
Ryan
-----Original Message-----
From: tutor-bounces+ryan=acceleration.net at python.org [mailto:tutor-bounces+ryan=acceleration.net at python.org] On Behalf Of Max Noel
Sent: Friday, January 21, 2005 11:33 AM
To: Tutor Tutor
Subject: [Tutor] Importing multiple files as a single module?
Hi everyone,
Having learnt OOP with C++, and most of my OOP experience being with
Java, I'm used to storing my classes in one file for each class. I find
it tidier and easier to read/debug.
However, when I try to do the same in Python, each file corresponds to
a module with a single class in it.
Is there a way to obtain the same result in Python as in Java? That
is, I'd like to have the following on my hard drive:
foo/
Bar.py
Baz.py
Where Bar.py and Baz.py each contain a single class (Bar and Baz).
Then, from Python, I'd import the foo module (import foo) and then
access the classes with foo.Bar and foo.Baz (instead of foo.Bar.Bar and
foo.Baz.Baz, which is what I have now). Being able to use Bar in Baz.py
would of course be a nice side effect.
Any ideas? Or am I trying to do things in a very non-Pythonic way? If
so, how am I supposed to organize my OOP code, especially given the
absence of a "real" IDE for Python?
Thanks for your attention,
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting
and sweating as you run through my corridors... How can you challenge a
perfect, immortal machine?"
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list