How would I go about making a file open. Not the way you might think.

Larry Bates larry.bates at websafe.com
Thu Aug 23 16:45:21 EDT 2007


Hendrik van Rooyen wrote:
> Lamonte Harris  wrote:
> 
>> Basically you can open a file by double clicking, and by default it would open
> w/ what every program you have it set >to.  Most text files would open in
> notepad.  How can I make a txt open so that notepad opens w/ the content in it
> by >using just python.
> 
> I asked this question just yesterday - and Tim Golden answered:
> 
> os.startfile()
> 
> - Hendrik
> 
Actually os.startfile('filename.txt') will open the file with whatever 
application is associated with .txt files on that machine.  That could be 
different from notepad if the user has chosen to override the defaults.

os.system('notepad.exe c:\\junk.txt')

will force notepad.exe to load and it will load the file specified.

All depends on what you want to do.

-Larry




More information about the Python-list mailing list