Re: organizing your scripts, with plenty of re-use

2009-10-19 Thread bukzor
On Oct 15, 4:30 pm, bukzor wrote: > On Oct 13, 3:20 pm, "Gabriel Genellina" > wrote: > > > > > > > En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió: > > > > The only way to get your packages on the PYTHONPATH currently is to: > > >    * install the packages to site-packages  (I don't have acces

Re: organizing your scripts, with plenty of re-use

2009-10-15 Thread bukzor
On Oct 13, 3:20 pm, "Gabriel Genellina" wrote: > En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió: > > > The only way to get your packages on the PYTHONPATH currently is to: > >    * install the packages to site-packages  (I don't have access) > >    * edit the PYTHONPATH all users' environment

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió: The only way to get your packages on the PYTHONPATH currently is to: * install the packages to site-packages (I don't have access) * edit the PYTHONPATH all users' environment (again, no access) * create some boilerplate that edits s

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 13, 9:37 am, Ethan Furman wrote: > Buck wrote: > >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. > > I don't think we mean the same thing by "zero

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Stef Mientki
Stephen Hansen wrote: On Mon, Oct 12, 2009 at 4:15 PM, Stef Mientki > wrote: Hierarchical choices are done on todays knowledge, tomorrow we might have different views and want/need to arrange things in another way. An otter may become a reptile ;

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Stef Mientki
[snip] The key is to put all the core functionality into a package, and place the package where Python can find it. Also, it's a good idea to use relative imports from inside the package. There is no need to juggle with sys.path nor even set PYTHONPATH nor import __main__ nor play any stra

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 13:28:05 -0300, Buck escribió: On Oct 12, 3:34 pm, "Gabriel Genellina" wrote: Quoting Steven D'Aprano   (changing names slightly): """You would benefit greatly from separating the interface from the backend. You should arrange matters so that the users see something like t

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Ethan Furman
Buck wrote: [snip] 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 workaro

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 12, 3:34 pm, "Gabriel Genellina" wrote: > En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: > > > On Oct 10, 9:44 am, "Gabriel Genellina" > > wrote: > >> The good thing is that, if the backend package is properly installed   > >> somewhere in the Python path ... it still works with no mo

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 12, 4:30 pm, Carl Banks wrote: > On Oct 12, 11:24 am, Buck wrote: > > > On Oct 10, 9:44 am, "Gabriel Genellina" > > 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

Re: [OT] organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 03:48:00 -0300, Dennis Lee Bieber escribió: On Mon, 12 Oct 2009 16:36:58 -0700, Ethan Furman declaimed the following in gmane.comp.python.general: coffe table, you look in your car, etc, etc, and so forth. If you move a file in a package to somewhere else, and you don't

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Stephen Hansen
On Mon, Oct 12, 2009 at 4:15 PM, Stef Mientki wrote: > Hierarchical choices are done on todays knowledge, tomorrow we might have > different views and want/need to arrange things in another way. > An otter may become a reptile ;-) > So from the human viewpoint the following should be possible (and

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread greg
Stef Mientki wrote: - I can move the complete project anywhere I like and it should still work without any modifications (when I move my desk I can still do my work) Gabriel's organisation satisfies that. - I can move any file in he project to any other place in the project and again everyth

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Ethan Furman
Stef Mientki wrote: Gabriel Genellina wrote: [snip] That's what I meant to say. It IS a zero-installation schema, and it also works if you properly install the package. Quoting Steven D'Aprano (changing names slightly): """You would benefit greatly from separating the interface from the

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Carl Banks
On Oct 12, 11:24 am, Buck wrote: > On Oct 10, 9:44 am, "Gabriel Genellina" > 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 ea

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 19:07:38 -0300, Buck escribió: On Oct 10, 1:57 am, Steven D'Aprano wrote: #!/usr/bin/python import os, sys if __name__ == '__main__':     # find out where we are, and add it to the path     [...] That's not a lot of boilerplate for a script. My issues with boilerplate a

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Stef Mientki
Gabriel Genellina wrote: En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" 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-i

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" 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. I

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" 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. I

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Buck
On Oct 10, 1:57 am, Steven D'Aprano wrote: > #!/usr/bin/python > import os, sys > > if __name__ == '__main__': >     # find out where we are, and add it to the path >     location = __import__('__main__').__file__ >     location = os.path.dirname(location) >     if location not in sys.path: >    

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Buck
On Oct 10, 9:44 am, "Gabriel Genellina" 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

Re: organizing your scripts, with plenty of re-use

2009-10-11 Thread Steven D'Aprano
On Sat, 10 Oct 2009 13:44:18 -0300, Gabriel Genellina wrote: >>> The frustrating thing, for me, is that all these requirements are met >>> if you leave the scripts in jumbled into a flat directory. >> >> I bet that's not true. I bet that they Just Work only if the user cd's >> into the directory f

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Ethan Furman
Gabriel Genellina wrote: En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/ +-- horse.py +-- o

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/ +-- horse.py +-- o

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Steven D'Aprano
On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: > Here's a scenario. A user does a cvs checkout into some arbitrary > directory and sees this: > > project/ > +-- python/ > +-- animals.py > +-- mammals/ > +-- horse.py > +-- otter.py > +-- reptiles/ > +-- gator.p

Re: organizing your scripts, with plenty of re-use

2009-10-09 Thread Carl Banks
On Oct 9, 4:37 pm, Buck wrote: > We don't have any such convention. The production code is at a well- > known path, but I need the code to be fully relocatable (cp -r /known/ > path ~/mydir) for testing purposes. > > Here's a scenario. A user does a cvs checkout into some arbitrary > directory and

Re: organizing your scripts, with plenty of re-use

2009-10-09 Thread Buck
On Oct 5, 8:12 pm, Steven D'Aprano wrote: > The Original Poster is confusing installation difficulties with code > organization -- his problem is that users have special requirements for > installation, and he's trying to work around those requirements by > organizing his code differently. I beli

Re: organizing your scripts, with plenty of re-use

2009-10-09 Thread Buck
On Oct 5, 2:15 pm, "Rami Chowdhury" wrote: > On Mon, 05 Oct 2009 13:46:09 -0700, Buck wrote: > > Thanks. I think we're getting closer to the core of this. > > > To restate my problem more simply: > > > My core goal is to have my scripts in some sort of organization better > > than a single direct

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread catafest
I think the basically you need to write one python script name it __init__.py If you want this script may include functions to reading yours scripts from folder. Put this script in each folder and you use Margie solution . This allow you to use import from each folder . -- http://mail.python.org/m

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread Gabriel Genellina
En Mon, 05 Oct 2009 18:15:15 -0300, Rami Chowdhury escribió: On Mon, 05 Oct 2009 13:46:09 -0700, Buck wrote: Thanks. I think we're getting closer to the core of this. To restate my problem more simply: My core goal is to have my scripts in some sort of organization better than a single d

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread Processor-Dev1l
On Oct 5, 8:29 pm, Robert Kern wrote: > On 2009-10-05 12:42 PM, Buck wrote: > > > > >> With the package layout, you would just do: > > >>     from parrot.sleeping import sleeping_in_a_bed > >>     from parrot.feeding.eating import eat_cracker > > >> This is really much more straightforward than yo

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Steven D'Aprano
On Mon, 05 Oct 2009 16:46:12 -0700, Carl Banks wrote: > Notice the key idea in all of this: ONE script. When you design it that > a file can be used either as a script or as a module, you are asking for > trouble. I agree with everything you said in your post *except* that final comment. The ba

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Carl Banks
On Oct 5, 1:46 pm, Buck wrote: > Thanks. I think we're getting closer to the core of this. > > To restate my problem more simply: > > My core goal is to have my scripts in some sort of organization better > than a single directory, and still have plenty of re-use between them. > The only way I can

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Robert Kern
On 2009-10-05 15:33 PM, Margie wrote: I think he is looking for a way for users to be able to use scripts/ myscript.py (which imports parrot) without having to change their PYTHON path with something like this: $ export PYTHONPATH=~/LocalToolCheckouts/:$PYTHONPATH I'm guessing that Buck ha

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Rami Chowdhury
On Mon, 05 Oct 2009 13:46:09 -0700, Buck wrote: Thanks. I think we're getting closer to the core of this. To restate my problem more simply: My core goal is to have my scripts in some sort of organization better than a single directory, and still have plenty of re-use between them. The only w

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Buck
Thanks. I think we're getting closer to the core of this. To restate my problem more simply: My core goal is to have my scripts in some sort of organization better than a single directory, and still have plenty of re-use between them. The only way I can see to implement this is to have 10+ lines

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Margie
On Oct 5, 12:34 pm, Robert Kern wrote: > On 2009-10-05 13:48 PM, Buck wrote: > > > > > On Oct 5, 11:29 am, Robert Kern  wrote: > >> On 2009-10-05 12:42 PM, Buck wrote: > > With the package layout, you would just do: > >      from parrot.sleeping import sleeping_in_a_bed >      from

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Robert Kern
On 2009-10-05 13:48 PM, Buck wrote: On Oct 5, 11:29 am, Robert Kern wrote: On 2009-10-05 12:42 PM, Buck wrote: With the package layout, you would just do: from parrot.sleeping import sleeping_in_a_bed from parrot.feeding.eating import eat_cracker This is really much more str

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Buck
On Oct 5, 11:29 am, Robert Kern wrote: > On 2009-10-05 12:42 PM, Buck wrote: > > > > >> With the package layout, you would just do: > > >>     from parrot.sleeping import sleeping_in_a_bed > >>     from parrot.feeding.eating import eat_cracker > > >> This is really much more straightforward than y

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Robert Kern
On 2009-10-05 12:42 PM, Buck wrote: With the package layout, you would just do: from parrot.sleeping import sleeping_in_a_bed from parrot.feeding.eating import eat_cracker This is really much more straightforward than you are making it out to be. As in the OP, I need things to "Just

Re: organizing your scripts, with plenty of re-use

2009-10-05 Thread Buck
> > With the package layout, you would just do: > >    from parrot.sleeping import sleeping_in_a_bed >    from parrot.feeding.eating import eat_cracker > > This is really much more straightforward than you are making it out to be. > As in the OP, I need things to "Just Work" without installation r

Re: organizing your scripts, with plenty of re-use

2009-10-04 Thread Robert Kern
On 2009-10-04 10:48 AM, Stef Mientki wrote: Steven D'Aprano wrote: On Sat, 03 Oct 2009 10:24:13 +0200, Stef Mientki wrote: 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

Re: organizing your scripts, with plenty of re-use

2009-10-04 Thread Stef Mientki
Steven D'Aprano wrote: On Sat, 03 Oct 2009 10:24:13 +0200, Stef Mientki wrote: 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 I find that fascinating. You haven't

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Donn
Great description - wish the Python docs could be as clear. Thanks. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Steven D'Aprano
On Sat, 03 Oct 2009 10:24:13 +0200, Stef Mientki wrote: > 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 I find that fascinating. You haven't used packages because you don

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Steven D'Aprano
On Fri, 02 Oct 2009 18:14:44 -0700, 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, A package is a special arrangement of folder + modules. To be a package, there must be a file called __init__.py in the fol

Re: organizing your scripts, with plenty of re-use

2009-10-03 Thread Stef Mientki
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.

organizing your scripts, with plenty of re-use

2009-10-02 Thread bukzor
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