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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -