[Tutor] droplet like behaviour in Python

Nick Raptis airscorp at otenet.gr
Tue Aug 11 21:45:48 CEST 2009


pedro wrote:
>
> #!/usr/bin/env python
> # encoding: utf-8
> import sys
> theFilePath = sys.argv[1]
> print theFilePath
>
>
> But when I try to drop something on it nothing happens. Sorry I guess 
> there is something fundamental that I am missing.
> Pete
>
>

Pedro, I'll reply to this message instead of the last one because, I 
actually tried the little script you have there, and it does work
I'm on Windows though.

Well, my version of your script is this:
-------------------------
import sys
for arg in sys.argv:
    print arg

raw_input()
-------------------------

The raw_input() at the end is what keeps the window open so I can see 
that something really happened before the window closed.
When I drop a file into my script, it prints two lines: The script 
filename and the filename of the file I dropped.
So I call it a win.

I don't know how it behaves in mac, but please try and tell. (Also put 
your usual #!/usr/bin/env python in there to work for you)

Nick


More information about the Tutor mailing list