plateform info.

Discussion in 'Python' started by Monu Agrawal, Sep 20, 2005.

  1. Monu Agrawal

    Monu Agrawal Guest

    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?
     
    Monu Agrawal, Sep 20, 2005
    #1
    1. Advertising

  2. Monu Agrawal

    Juho Schultz Guest

    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...
     
    Juho Schultz, Sep 20, 2005
    #2
    1. Advertising

  3. 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
     
    Mikael Olofsson, Sep 20, 2005
    #3
  4. Monu Agrawal

    Maurice LING Guest

    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
     
    Maurice LING, Sep 22, 2005
    #4
  5. Monu Agrawal

    Maurice LING Guest

    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
     
    Maurice LING, Sep 22, 2005
    #5
  6. Monu Agrawal

    Mike Meyer Guest

    Maurice LING <> 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 <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Sep 22, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P. Barthelemy
    Replies:
    0
    Views:
    355
    P. Barthelemy
    May 17, 2005
  2. Replies:
    1
    Views:
    295
    Jonathan Mcdougall
    May 6, 2006
  3. mokhta

    C++ in a windows plateform

    mokhta, Apr 8, 2007, in forum: C++
    Replies:
    3
    Views:
    312
  4. Replies:
    0
    Views:
    168
  5. Replies:
    4
    Views:
    208
    Andreas Leitgeb
    Oct 12, 2013
Loading...

Share This Page