Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > detecting the operating system

Reply
Thread Tools

detecting the operating system

 
 
James Kew
Guest
Posts: n/a
 
      03-01-2004
"Josiah Carlson" <(E-Mail Removed)> wrote in message
news:c1thq4$129$(E-Mail Removed)...
> > os.path.expanduser("~") ?

>
> Doesn't work for all platforms. Occasionally in windows that will
> expand to %USERPROFILE%, which you then have to resolve with os.getenv.


I'm also told (in email) it doesn't work under Win98.

Which is a shame, 'cause it's quite handy...

James


 
Reply With Quote
 
 
 
 
Russell E. Owen
Guest
Posts: n/a
 
      03-02-2004
In article <c1mtcj$ofv$(E-Mail Removed)>,
"Woojay Jeon" <wjj{nospam}(E-Mail Removed)> wrote:

>OK, I tried a Google search on this Usenet group but couldn't find a
>solution, so I'm posting my question here (if there's a better archive than
>the one in Google, please let me know).
>
>Does anybody know how to detect the operating system under which the current
>Python program is running, especially whether it's Windows or Unix? I have a
>program that needs to search for files in "c:\test" if it's running under
>Windows, and "/home/user/test" if it's running under Unix, so the simplest
>solution I can think of is to detect the operating system, but if anyone
>could suggest a workaround, that would also be fine.


To simply differentiate between Windows and everything else, try
importing a Windows-only library, such as _winreg or winsound:

try:
import _winreg
# at this point it's some flavor of Windows
except ImportError:
# not Windows

-- Russell
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting both computers with different operating system together naderbd Wireless Networking 1 07-29-2005 12:47 AM
Sun to Give Out Operating System for Free Rich Firefox 7 11-16-2004 07:47 PM
How to get the Operating System info like ( Wireless info, Wireless connection) Vasanth Perl 0 06-28-2004 08:56 AM
Re: 32 bit operating system Consultant MCSE 0 01-08-2004 02:58 PM
Re: 32 bit operating system Politician Spock MCSE 0 01-08-2004 02:55 PM



Advertisments