Re: How to get computer name



"pitarda" <pitarda@xxxxxxxxx> writes:

How do I get the computer name in python?

You can use the os module to get it from your environment.

>>> import os
>>> os.getenv('HOSTNAME')
'calvin.watterson'

Depending on your operating system, the environment variable you need
might have a different name. For example, I think in Windows you
might try

>>> os.getenv('COMPUTERNAME')

You can see all of the environment variables currently available with

>>> os.environ

I hope this helps,

Tim
.



Relevant Pages

  • Re: Environment variable building platform
    ... You need to convert the environment variables to ... or globally in sources.cmn in the root of you platform. ... slightly change the code in the platform depending on ... Settings, Environment, and setting a variable there which I hoped to ...
    (microsoft.public.windowsce.platbuilder)
  • Re: how can i change the temporary directory of windows
    ... In Windows 2000, right click My Computer, choose the Advanced tab, and click ... "Environment Variables". ... It will move around a bit depending on which ... > i want to change the windows temporary directory which is retrived ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Environment Variable Information
    ... Autoexec.bat that Windows XP will read are the lines that begin SET or PATH. ... So I got to create a Perl script which will verify the ... Windows XP machine which stores this information apart from registry. ... System environment variables are in the following Registry key: ...
    (microsoft.public.windowsxp.general)
  • Re: DTHML Editor not found. What?
    ... Help to find how to set Environment variables and get to the point where we can do that. ... First though go to C:\Program Files\Common Files\Microsoft Shared\Triedit in Windows Explorer. ... But let me try to explain how to register a ocx file again. ... Type set then hit ENTER. ...
    (microsoft.public.outlook.general)
  • Re: Environment Variable Information
    ... Don't you just love secret programs. ... Autoexec.bat that Windows XP will read are the lines that begin SET or PATH. ... Windows XP machine which stores this information apart from registry. ... System environment variables are in the following Registry key: ...
    (microsoft.public.windowsxp.general)