Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Os.startfile in Windows.
#5
Look at webbrowser module.
webbrowser.open(filename) it can call os.startfile(), open, xdg-open where appropriate.

Source code
Unwillingly supported Snooty
Quote:Note that on some platforms, trying to open a filename using this function,may work and start the operating system’s associated program.
However, this is neither supported nor portable.

Test:
import webbrowser

webbrowser.open('Alarm.wav')
import os

os.startfile('Alarm.wav')
Both work the same and open program that file association with .wav in Windows.

This will not work as can not find file association for .wav.
import subprocess

subprocess.run(['Alarm.wav']) 
Discussion about making os.startfile work cross platform,don't think they agree on something.
Reply


Messages In This Thread
Os.startfile in Windows. - by Gribouillis - Aug-01-2019, 07:35 AM
RE: Os.startfile in Windows. - by fishhook - Aug-01-2019, 07:50 AM
RE: Os.startfile in Windows. - by Gribouillis - Aug-01-2019, 07:59 AM
RE: Os.startfile in Windows. - by fishhook - Aug-01-2019, 08:35 AM
RE: Os.startfile in Windows. - by snippsat - Aug-01-2019, 02:35 PM
RE: Os.startfile in Windows. - by Gribouillis - Aug-02-2019, 05:39 AM
RE: Os.startfile in Windows. - by Malt - Aug-02-2019, 06:55 AM
RE: Os.startfile in Windows. - by Gribouillis - Aug-02-2019, 07:28 AM
RE: Os.startfile in Windows. - by snippsat - Aug-02-2019, 08:20 PM
RE: Os.startfile in Windows. - by Gribouillis - Aug-02-2019, 09:06 PM
RE: Os.startfile in Windows. - by snippsat - Aug-02-2019, 09:20 PM
RE: Os.startfile in Windows. - by Gribouillis - Aug-03-2019, 07:35 AM
RE: Os.startfile in Windows. - by Malt - Aug-08-2019, 05:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020