title: Python on Linux: get host name in /etc/hostname
body: <p>From within a Python script I am trying to get the host name in a Linux box. It is a Debian GNU/Linux Amazon EC2 instance. I have set the correct name in <code>/etc/hostname</code>. The recommended solution <code>socket.gethostname()</code> is not working: it shows the ip- plus the IP tuple.</p>
  
  <p>I have searched on StackOverflow and nothing is coming out, e.g. <a href="https://stackoverflow.com/questions/4271740/how-can-i-use-python-to-get-the-system-name">here</a>. <code>socket.getfqdn()</code> is even worse: it yields <code>ip-[IP tuple].eu-west-1.compute.internal</code>.</p>
  
  <p>Am I doing something wrong, or is there no clean solution to get the hostname in <code>/etc/hostname</code>? Of course the back-up solution is to read the file <code>etc/hostname</code> itself, but something so inherently platform-dependent is somehow too aberrant. Thanks!</p>