Python application launcher (for Python code)

Steve D'Aprano steve+python at pearwood.info
Mon Feb 20 20:25:14 EST 2017


On Tue, 21 Feb 2017 02:44 am, Deborah Swanson wrote:

[...]
> Basically, I now have quite a few Python programs I use frequently, and
> as time goes on my collection and uses of it will grow. Right now I just
> want a way to select which one I'd like to run and run it. I'd like it
> to be a standalone application and some sort of system of categories
> would be nice.

Here's a possible work-flow that might be suitable for you. I'm going to
write it in Linux-speak, you can hopefully translate it to Windows
yourself.

(1) Organise your scripts into separate directories according to your
preferred way of categorising them:

/home/steve/python/fun/
/home/steve/python/serious/
/home/steve/python/work/

Move each script into the appropriate directory.

(2) Add each category to the PYTHONPATH. One easy way to do so is by adding
the directories to a .pth file. Create the file:

/home/steve/.local/lib/python3.5/site-packages/default.pth

(the name is not important so long as it ends with .pth; the location is)

containing the three lines:

/home/steve/python/fun/
/home/steve/python/serious/
/home/steve/python/work/


See the documentation for the site module for more detail:

https://docs.python.org/3/library/site.html



(3) Now you can run any of your scripts by name, without caring precisely
where it is:

python3 -m myscript


or you can explicitly choose one:

cd ~  # change to my home directory
python3 python/fun/myscript.py


> I'm migrating tasks I've always done in Excel to Python, and I have a
> sketchy idea of features I'd like to open Excel with, but I hate Excel
> VBA so much that I haven't written an on_Open macro for Excel yet. 

You might consider using LibreOffice. It is intended to be backwards
compatible with Excel, but is scriptable using four different languages:

Basic
Python
Javascript
BeanShell


Start here:

https://duckduckgo.com/html/?q=scripting+libreoffice



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list