Organizing Code - Packages

xkenneth xkenneth at
Sat Sep 8 21:42:19 CEST 2007

On Sep 7, 2:04 pm, Wildemar Wildenburger
<lasses_w... at> wrote:
> Paul Rudin wrote:
> > xkenneth <xkenn... at> writes:
> >>> Ah, yes, a couple of things:
> >>> - avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens
> >> Yes but i find it hard to edit classes easily when I have more than
> >> one class per file.
> > Why?
> Scroll-Blindness would be a good reason.
> It would however be completely rediculous to create a file for every
> 10-liner class you have (and I have found that Python classes tend to be
> rather short).
> /

Yes I agree, "Scroll-Blindness" it just gets long and confusing.
Navigating isn't so bad (emacs) here. I have another question for
something I don't quite understand.

How do import statements that are declared at the top of a python
module work?

for instance....

from MyModule.Objects import *

class Class:
      def function:
           #here i cannot access the things that should have been
imported from the above statement
           #i printed the dir() function to verify this

This happens when I'm using the Class i just defined from another
python script. I can understand if that statement at the top if not
being executed when I import the above defined class, if so, I need to
access the classes from the other modules, so where do I put the
import statement? Is it proper to put import statements inside of
class function definitions? This solves my problem but seems VERY
incorrect coming from my old C/C++ ways.

Thanks Again!


More information about the Python-list mailing list