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

2009-10-19 Thread bukzor
On Oct 15, 4:30 pm, bukzor workithar...@gmail.com wrote: On Oct 13, 3:20 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 13 Oct 2009 17:38:44 -0300, Buck workithar...@gmail.com escribió: The only way to get your packages on the PYTHONPATH currently is to:    * install

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

2009-10-15 Thread bukzor
On Oct 13, 3:20 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 13 Oct 2009 17:38:44 -0300, Buck workithar...@gmail.com 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

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 wlfr...@ix.netcom.com escribió: On Mon, 12 Oct 2009 16:36:58 -0700, Ethan Furman et...@stoneleaf.us 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

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

2009-10-13 Thread Buck
On Oct 12, 4:30 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 12, 11:24 am, Buck workithar...@gmail.com wrote: On Oct 10, 9:44 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: The good thing is that, if the backend package is properly installed   somewhere in the Python

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

2009-10-13 Thread Buck
On Oct 12, 3:34 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Mon, 12 Oct 2009 15:24:34 -0300, Buck workithar...@gmail.com escribió: On Oct 10, 9:44 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: The good thing is that, if the backend package is properly installed  

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

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 workithar...@gmail.com escribió: On Oct 12, 3:34 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: Quoting Steven D'Aprano   (changing names slightly): You would benefit greatly from separating the interface from the backend. You should arrange

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

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 stef.mien...@gmail.com mailto:stef.mien...@gmail.com 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

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

2009-10-13 Thread Buck
On Oct 13, 9:37 am, Ethan Furman et...@stoneleaf.us 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

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

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

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

2009-10-12 Thread Carl Banks
On Oct 12, 11:24 am, Buck workithar...@gmail.com wrote: On Oct 10, 9:44 am, Gabriel Genellina gagsl-...@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

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 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

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 stef.mien...@gmail.comwrote: 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

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 first. In

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.py

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 st...@remove-this-cybersource.com.au 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 +--

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 st...@remove-this-cybersource.com.au 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 +--

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 st...@remove-this-cybersource.com.au 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/

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

2009-10-07 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 . --

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

2009-10-06 Thread Processor-Dev1l
On Oct 5, 8:29 pm, Robert Kern robert.k...@gmail.com 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

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 rami.chowdh...@gmail.com escribió: On Mon, 05 Oct 2009 13:46:09 -0700, Buck workithar...@gmail.com 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

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

2009-10-05 Thread Buck
On Oct 5, 11:29 am, Robert Kern robert.k...@gmail.com 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

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 Kernrobert.k...@gmail.com 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

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

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

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 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

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-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-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:

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

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'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

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