os.startfile() - one or two arguments?

Thomas Heller theller at python.net
Fri Apr 28 11:23:17 EDT 2006


BartlebyScrivener wrote:
> Can any Windows user give a working example of adding a "command verb"
> to os.startfile()?
> 
> When I try it, it squawks that it takes only one argument.
> 
>>>> os.startfile('d:/','explore')
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> TypeError: startfile() takes exactly 1 argument (2 given)
> 
> from os module
> 
> startfile(  	path[, operation])
>     Start a file with its associated application.
> 
>     When operation is not specified or 'open', this acts like
> double-clicking the file in Windows Explorer, or giving the file name
> as an argument to the start command from the interactive command shell:
> the file is opened with whatever application (if any) its extension is
> associated.
> 
>     When another operation is given, it must be a ``command verb'' that
> specifies what should be done with the file. Common verbs documented by
> Microsoft are 'print' and 'edit' (to be used on files) as well as
> 'explore' and 'find' (to be used on directories).

The optional second argument was added in Python 2.5 (currently in alpha).
These examples work for me, with python 2.5a2:

os.startfile("Rechnung-28.10.pdf", "print")
os.startfile("c:\\", "explore")

Thomas




More information about the Python-list mailing list