Your search query "linkto%3A%22Powerful Python One-Liners%2FHostname%22" didn't return any results. Please change some terms and refer to HelpOnSearching for more information.
(!) Consider performing a full-text search with your search terms.

Clear message


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


from socket import gethostname; print gethostname()


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()

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