194
Comment:
|
← Revision 8 as of 2009-03-07 22:21:04 ⇥
614
|
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: |
{{{from socket import gethostname; print gethostname()}}} | |
Line 7: | Line 7: |
{{{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]}}} [[synthesis]]: -- use {{{import platform; print platform.node()}}} |
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]
synthesis: -- use import platform; print platform.node()