organizing your scripts, with plenty of re-use

Buck workitharder at gmail.com
Tue Oct 13 18:23:34 CEST 2009


On Oct 12, 4:30 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
> On Oct 12, 11:24 am, Buck <workithar... at gmail.com> wrote:
>
> > On Oct 10, 9:44 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> > wrote:
>
> > > The good thing is that, if the backend package is properly installed  
> > > somewhere in the Python path ... it still works with no modifications.
>
> > I'd like to get to zero-installation if possible. It's easy with
> > simple python scripts, why not packages too? I know the technical
> > reasons, but I haven't heard any practical reasons.
>
> No it's purely technical.  Well mostly technical (there's a minor
> issue of how a script would figure out its "root").  No language is
> perfect, not even Python, and sometimes you just have to deal with
> things the way they are.

Python is the closest I've seen. I'd like to deal with this wart if we
can.

> We're trying to help you with workarounds, but it seems like you just
> want to vent more than you want an actual solution.

Steven had the nicest workaround (with the location = __import__
('__main__').__file__ trick), but none of them solve the problem of
the OP: organization of runnable scripts. So far it's been required to
place all runnable scripts directly above any used packages. The
workaround that Gabriel has been touting requires this too.

Maybe it seems like I'm venting when I shoot down these workarounds,
but my real aim is to find some sort of consensus, either that there
is a solution, or an unsolved problem. I'd be delighted with a
solution, but none have been acceptable so far (as I explained in
aggravating detail earlier).

If I can find consensus that this is a real problem, not just my
personal nit-pick, then I'd be willing to donate my time to design,
write and push through a PEP for this purpose. I believe it can be
done neatly with just three new standard functions, but it's premature
to discuss that.

> > If the reasons are purely technical, it smells like a PEP to me.
>
> Good luck with that.  I'd wholeheartedly support a good alternative,
Thanks.

> I just want to warn you that it's not a simple issue to fix, it would be
> involve spectacular and highly backwards-incompatible changes.
> --Carl Banks

I don't believe that's true, but I think that's a separate discussion.



More information about the Python-list mailing list