title: python - getting the MAC address properly in Windows
body: <p>I'm using Windows 7 and Python 2.6. I would like to get the MAC address of my network interface. </p>
  
  <hr>
  
  <p>I've tried using the <code>wmi</code> module:</p>
  
  <pre><code>def get_mac_address():
  
      c = wmi.WMI ()
      for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
          return  interface.MACAddress
  </code></pre>
  
  <p>However, experienced issues when executed without internet connectivity. </p>
  
  <hr>
  
  <p>I've tried using the <code>uuid</code> module: </p>
  
  <pre><code>from uuid import getnode 
  print getnode()
  </code></pre>
  
  <p>However, return value is a 48 byte representation of the MAC address</p>
  
  <pre><code>66610803803052
  </code></pre>
  
  <hr>
  
  <p>1) How should I convert the given number to <code>ff:ff:ff:ff:ff:ff</code> format?<br>
  2) Is there a better way to get the MAC address?</p>