[Pythonmac-SIG] Running Multiple Python Scripts?

Bob Ippolito bob@redivi.com
Fri, 26 Apr 2002 19:12:47 -0400


Dan,

In response to this message and your "Command Line Pitfalls to Avoid" 
message, I implore you to take a closer read at this thread on 
wxpython-mac (which you started, actually):  
http://lists.wxwindows.org/pipermail/wxpython-mac/2002-April/000211.html

To keep it short, use the pythonw script, not python when starting GUI 
python scripts.  Double clicking on two .py files will never open two 
python scripts without significant redesign of the way Python.app 
works.   MacPython (OS9) had this problem as well, IIRC, which was more 
of a problem because it was your *only* python given that there was no 
command line.  The reason for this in OS X is because of the way 
WindowServer works, it will only give an app *one* dock representation 
if executed from a bundle, nomatter how hard you try.. If the app is 
already loaded it sends a "document open" carbon event to the app 
instead of starting the app and sending the message.  I don't really 
feel like getting into all of the details right now, but don't expect 
this to work anytime soon unless there's a magical undocumented 
Info.plist key/value pair you can use to make this happen 
automatically.  I doubt it.

Ideally I think there will be a way for one to create their own 
application bundles using python, as one does with Applescript and can 
do with Perl, Ruby, F-Script these days as well.  .py files are really 
meant for the command line, they're not documents, they're programs.  
Associating .py programs with another program (python.app) that treats 
them as documents (because there is no other way in OS X AFAIK) is 
obviously not going to be ideal since a program can only have one set of 
menus, one main thread, etc.  If we were to write an "python.app" that 
allowed multiple dock/menu representation on double click of .py files 
we would have to develop something akin to apple's .jar starter for 
java, which is altogether possible but you have to do undocumented stuff 
(I know, because I reverse-engineered this process for my own purposes).

Your user shell is tcsh, the system's default shell is not.  It is 
/bin/sh, which is a symlink to zsh for whatever reason.  So that 
explains the discrepancy in console messages.

-bob

On Friday, April 26, 2002, at 05:01 PM, Dan Shafer wrote:

> It appears to me that it is not yet possible with MachoPython 2.2.1 on 
> OS X 10.1.4 to run two Python scripts at the same time.
>
> Whether I launch scripts by double-clicking, dock-launching or 
> command-line launch with the open command, if I already have a Python 
> script running when I do that, I get a "boing" sound  and the 
> PythonInterpreter gets brought to the front. If I then quit the running 
> script I can launch another.
>
> This could cause some problems for the PythonCard team because we tend 
> to use os.system and os.spawnv to launch scripts from within scripts. 
> This does not work on my system. Strangely, when I launch a 
> PythonCardPrototype app that launches other scripts and click on a 
> button to launch such a script, the Console message is: "zsh: 
> permission denied: /" which is passing strange becaus I use tcsh, not 
> zsh.