Differences between revisions 3 and 7 (spanning 4 versions)
Revision 3 as of 2008-06-25 18:28:25
Size: 430
Editor: CameronLaird
Comment:
Revision 7 as of 2008-11-19 08:39:51
Size: 544
Editor: 194
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

This is a simple ["Powerful Python One-Liners"].  It prints the systems's hostname to the screen.   
This is a simple [[Powerful Python One-Liners]]. It prints the systems's hostname to the screen.
Line 6: Line 5:
Line 10: Line 8:
This program has been uploaded to the Wiki.  You can download it as an attachment from this page. This program has been uploaded to the Wiki. You can download it as an attachment from this page.
Line 12: Line 10:


Well, sometimes.  A lighter-weight variant that sometimes is desirable is
Well, sometimes. A lighter-weight variant with desirable properties is
Line 17: Line 13:

[[lwickjr]]: --which doesn`t seem to work on Windows. :(

[[snark]]: -- use {{{import platform; print platform.uname()[1]}}}

Description

This is a simple Powerful Python One-Liners. It prints the systems's hostname to the screen.

Code

from socket import gethostname; print gethostname()

Download

This program has been uploaded to the Wiki. You can download it as an attachment from this page.

Well, sometimes. A lighter-weight variant with desirable properties is

import os; print os.uname()[1]

lwickjr: --which doesn`t seem to work on Windows. :(

snark: -- use import platform; print platform.uname()[1]

Powerful Python One-Liners/Hostname (last edited 2009-03-07 22:21:04 by adsl-75-30-178-145)

Unable to edit the page? See the FrontPage for instructions.