By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,036 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,036 IT Pros & Developers. It's quick & easy.

plateform info.

P: n/a
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?

Sep 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Monu Agrawal wrote:
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?


os.name - the value is "posix" for Linux/Unix, "nt" or "ce" for Windows,
and so on...
Sep 20 '05 #2

P: n/a
Monu Agrawal wrote:
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?


Will this help?
import sys
sys.platform

'win32'

There is also the platform module, that can give you a lot more
information about the your platform. Try help(platform).

/MiO
Sep 20 '05 #3

P: n/a
Mikael Olofsson wrote:
Monu Agrawal wrote:
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?

Will this help?
>>> import sys
>>> sys.platform

'win32'

There is also the platform module, that can give you a lot more
information about the your platform. Try help(platform).

/MiO


Adding onto this (which may be of need), but if this seems to be a
hijack, my apologies......

Is there a way of getting the path to the site-packages directory?
Considering that Mac OSX with Fink installs python libraries in
/sw/lib/python<version>, Mac OSX itself has python libraries in
/System/Library/Frameworks/Python.framework/Versions/<version>/lib, etc
etc...

maurice
Sep 22 '05 #4

P: n/a
Mikael Olofsson wrote:
Monu Agrawal wrote:
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?

Will this help?
>>> import sys
>>> sys.platform

'win32'

There is also the platform module, that can give you a lot more
information about the your platform. Try help(platform).

/MiO


Adding onto this (which may be of need), but if this seems to be a
hijack, my apologies......

Is there a way of getting the path to the site-packages directory?
Considering that Mac OSX with Fink installs python libraries in
/sw/lib/python<version>, Mac OSX itself has python libraries in
/System/Library/Frameworks/Python.framework/Versions/<version>/lib, etc
etc...

maurice
Sep 22 '05 #5

P: n/a
Maurice LING <ma*********@acm.org> writes:
Is there a way of getting the path to the site-packages directory?
import sys
import os
for dir in sys.path: .... if os.path.split(dir)[-1] == 'site-packages':
.... print dir
....
/usr/opt/lib/python2.4/site-packages


But there's seldom a reason to want this.
Considering that Mac OSX with Fink installs python libraries in
/sw/lib/python<version>, Mac OSX itself has python libraries in
/System/Library/Frameworks/Python.framework/Versions/<version>/lib, etc
etc...


And darwinportgs puts them in
/Library/Frameworks/Python.framework/Versions/<Version>/lib/...
but includes /opt/local/lib/python2.4/site-packages in sys.path.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.