In article <larpf5$3c1$1...@dont-email.me>, "James Harris" <james.harri...@gmail.com> wrote:
> "Andriy Kornatskyy" <andriy.kornats...@live.com> wrote in message > news:mailman.5329.1389450993.18130.python-l...@python.org... > > Sam, > > > > How about this? > > > > from uuid import getnode as get_mac > > '%012x' % get_mac() > > AIUI that will return a mac address even if there isn't one. That may or may > not suit the OP. Specifically, it says, "If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122". Keep in mind that 4122 is all about generating globally unique strings. The only reason it even talks about MAC addresses is in the context of one possible way to generate uuids. If your goal is to get the MAC address for some sort of networking reason, you need to bear in mind what James says below: > To the OP, depending on what you want to do remember that a machine can have > more than one mac address and that a mac address can differ from the > burned-in address (BIA) as some cards allow the effective mac address to be > changed in software. So it's possible that two machines could show the same > mac address. If you don't believe that two machines can have the same MAC address, look up Hot Standby Router Protocol. And if you don't believe a machine can ignore the BIA and assign a new MAC address in software, look up Decnet <insert derogatory gesture with sound effect here>. -- https://mail.python.org/mailman/listinfo/python-list