Re: How to get computer name
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: How to get computer name

From: Tim Heaney <theaney@cablespeed.com>
Date: Sat Apr 29 2006 - 18:57:47 CEST

"pitarda" <pitarda@gmail.com> 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
Received on Mon May 1 00:44:15 2006