Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30939

Re: Convert MAC to hex howto

From Johannes Graumann <johannes_graumann@web.de>
Subject Re: Convert MAC to hex howto
Followup-To gmane.comp.python.general
Date 2012-10-07 23:38 +0300
References <mailman.1931.1349639025.27098.python-list@python.org> <7xipamcazs.fsf@ruckus.brouhaha.com>
Newsgroups comp.lang.python
Message-ID <mailman.1938.1349642407.27098.python-list@python.org> (permalink)

Followups directed to: gmane.comp.python.general

Show all headers | View raw


Paul Rubin wrote:

> Johannes Graumann <johannes_graumann@web.de> writes:
>> '00:08:9b:ce:f5:d4'
>> ...
>> hexcall = "\\x".join(hexcall).decode('string_escape')
> 
> I think it's best not to mess with stuff like that.  Convert to integers
> then convert back:
> 
>   mac = '00:08:9b:ce:f5:d4'
>   hexcall = ''.join(chr(int(c,16)) for c in mac.split(':'))

Thanks to you as well!

Joh

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Convert MAC to hex howto Johannes Graumann <johannes_graumann@web.de> - 2012-10-07 22:44 +0300
  Re: Convert MAC to hex howto Paul Rubin <no.email@nospam.invalid> - 2012-10-07 12:56 -0700
    Re: Convert MAC to hex howto Johannes Graumann <johannes_graumann@web.de> - 2012-10-07 23:38 +0300

csiph-web