User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 427,316 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,850 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums

Starting Python

Join Date: Jul 2005
Location: France
Posts: 1,013
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 45
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Veteran Poster

Re: Starting Python

  #47  
Feb 13th, 2006
This small code allow you to list your computer's environment, things like processor, os, user and so on:
# list the environmental settings of your computer

import os

keys = os.environ.keys()
keys.sort()
for item in keys:
    print "%-22s : %s" % (item, os.environ[item])
As a bonus another small code to find the IP address of your computer:
# Get the IP address of the machine this program is running on
# or go to http://www.whatismyip.com/

import socket

print socket.gethostname()
print socket.getaddrinfo(socket.gethostname(), None)
# get just the IP address from the list's tuple
print socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
Networks using the TCP/IP protocol route messages based on the IP address of the destination. An IP address is a 32-bit numeric address written as four numbers separated by periods.
Reply With Quote  
All times are GMT -4. The time now is 2:41 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC