python - What is the correct way of getting a base (or short?) hostname? -
is there simpler/better or more pythonic way of getting base hostname?
base_hostname = socket.gethostname().split(".")[0] as example, how localhost below:
>>> socket.gethostname() 'localhost.localdomain' >>> socket.getfqdn() 'localhost.localdomain' >>> socket.gethostname().split('.')[0] 'localhost' i asking because suspect there similar os.path's abspath, basename, join, split, splitext, etc functions manipulate hostnames, haven't found yet.
Comments
Post a Comment