Organizing Python Code

Russell Wallace rwallace at esatclear.ie
Thu Oct 5 20:55:53 EDT 2000


Greg Ewing wrote:
> 
> Russell Wallace wrote, concerning "import *":
> >
> > What problems do you see it causing?
> 
> In my experience, the main thing you lose is the ability
> to easily track down which module a given identifier is
> coming from. This can be quite important when working on
> someone else's code, or your own code some time later.

Oh, I see.  Yes, I certainly find it important to be able to track down
where an identifier is coming from; if my import usage made that hard,
that'd be a big drawback.  But...

> Recently I had occasion to work on a Borland Pascal
> program written by someone else, consisting of a few
> dozen source files spread over several directories.
> I found myself wishing that Borland Pascal had a more
> explicit import mechanism than just "uses modulename".

...I don't understand where the difficulty is?

Pascal: grep "procedure foo" or "function foo" *.pas (unless my Pascal
is rustier than I think it is :))
C: grep foo *.h
Python: grep "def foo" *.py

and equivalents for definitions of classes, global variables etc.  I
find this easily works even for hundreds of source files of other
people's code that I'm not familiar with.

-- 
"To summarize the summary of the summary: people are a problem."
Russell Wallace
mailto:rwallace at esatclear.ie
http://www.esatclear.ie/~rwallace



More information about the Python-list mailing list