tags:

views:

752

answers:

3

I tried:

print os.name

And the output I got was:

:nt

However, I want output more like "Windows 98", or "Linux".

After suggestions in this question, I also tried:

import os
print os.name
import platform
print platform.system()
print platform.release()

And my output was:

Traceback (most recent call last):
  File "C:/Documents and Settings/BIU1LR/Desktop/python_programs/program/platform.py", line 3, in <module>
    import platform
  File "C:/Documents and Settings/BIU1LR/Desktop/python_programs/program\platform.py", line 4, in <module>
    print platform.system()
AttributeError: 'module' object has no attribute 'system'

I am using Python 2.5.2. What am I doing wrong?

+18  A: 

Try:

import platform
print platform.system(), platform.release()

I tried this on my computer with Python 2.6 and I got this as the output:

Windows XP

After your latest edits, I see that you called your script platform.py. This is causing a naming problem, as when you call platform.system() and platform.release(), it's looking in your file, and not Python's platform module. If you change the name of your file, all of your problems should be resolved.

Thomas Owens
+5  A: 

it is because you named your program "platform". Hence when importing the module "platform", your program is imported instead in a circular import.

Try renaming the file to test_platform.py, and it will work.

NicDumZ
A: 

import platform

platform.dist()

Raghvendra