run a .py script with cmd line args

Mike Driscoll kyosohma at gmail.com
Tue Aug 12 15:34:13 EDT 2008


On Aug 12, 2:20 pm, r <rt8... at gmail.com> wrote:
> i have a python text editor program(script) that i would like to run
> when a user clicks on .txt files.
> how do i run my script from windows,
> and send the filename to my script, so that my script can do:
>
> if len(sys.argv) > 1:
>     try:
>          self.LoadFile(sys.argv[1])  # load text into editor
>     except:
>         pass


The following thread explains one way to do it:

http://mail.python.org/pipermail/python-win32/2006-March/004360.html

You may also find the mimetypes module helpful:

http://docs.python.org/lib/module-mimetypes.html

Mike



More information about the Python-list mailing list