organizing your scripts, with plenty of re-use

Stef Mientki stef.mientki at gmail.com
Sat Oct 3 04:24:13 EDT 2009


bukzor wrote:
> I would assume that putting scripts into a folder with the aim of re-
> using pieces of them would be called a package, but since this is an
> "anti-pattern" according to Guido, apparently I'm wrong-headed here.
> (Reference: http://mail.python.org/pipermail/python-3000/2007-April/006793.html
> )
>
> Say you have ~50 scripts or so with lots of re-use (importing from
> each other a lot) and you want to organize them into folders. How do
> you do this simply?
>
>   
Interesting question, ...
... and although I've a working situation, I would like to see other 
answers.

In my situation I've an estimate of about 2000 scripts (in fact every 
script I ever wrote),
with about zero redundancy.
I still don't use (because I don't fully understand them) packages,
but by trial and error I found a reasonable good working solution,
with the following specifications
- (Almost) any script (what ever it uses from one of the other scripts 
can run standalone
- libraries that need another main program ( e.g. a grid component needs 
a GUI) can launch another main program to test itself
- All __init__ files are generated automatically
Although not containing the last ideas, here's an idea of what I do:
  http://mientki.ruhosting.nl/data_www/pylab_works/pw_importing.html
cheers,
Stef
> The intent is to have people be able to check out the directly from
> CVS and have the scripts "just work", even if they're not directly on
> the PYTHONPATH.
>
> This seems to be the best discussion on the topic, but the conclusion
> seemed to be that there's no good way. That seems unthinkable
> considering python's dedication to simplicity and elegance.
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/c44c769a72ca69fa/
>
>
> It looks like I'm basically restating this post, which sadly got
> dropped without further comment:
> http://mail.python.org/pipermail/python-3000/2007-April/006814.html
>   




More information about the Python-list mailing list