Fifty million ways to get the hostname, choose one.
import os,socket,platform,re print socket.gethostname() print platform.uname()[1] print platform.node()
But I couldn’t find a way to get the shortname without a system call to ‘hostname -s’. This is the best I could come up with, which would work with any of the above methods.
import os,re print re.sub(r'\..*', '', os.uname()[1])