Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63706
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.024 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'jan': 0.12; "''.join(l)": 0.16; 'colons': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:port': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'skip:l 30': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'mac': 0.33; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'shorter': 0.36; 'subject:?': 0.36; 'too': 0.37; 'that,': 0.38; 'little': 0.38; 'short': 0.38; '12,': 0.39; 'enough': 0.39; 'subject:get': 0.81; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=h8abOtZBjGIXgLOkIR1m6QNrBVhjIRnI+v+wM7J4jjs=; b=rMI9iDzsHFIaBEvn4ULiefLiIBdh3Vh3DSRtQ+m4Dt4EXxxXRh2YpubEmTVXj6MfV9 91lVuwKlSbpTw8J4zxdCJ09VgTQUyVp/r0wBdvG6McB4iI0ITDAzyxDhsUTA0wQLOyzH owAEX5aBIYXn5kxxAhWJcVAVqaQ8LXVh5zM5AQVBF6SW1lhj5EZZQTxfa1vISDswHYUA mhfPoP1vLkFWPJ2snoyTHlmwyM6XC4k+iQuMPRDZEKdRlAPsdeIZepm5gckysp8DQF3n buq14Vj8WMjV1eDShP5sI38jhceHO6KA8D1oxiPsZoKHLXeYhgC147iPVHuOSmp8CbjU 99yg== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.102.39 with SMTP id fl7mr18537065pab.43.1389451932338; Sat, 11 Jan 2014 06:52:12 -0800 (PST) |
| In-Reply-To | <BLU0-SMTP4386E5DFE51C2E3BD49827591B20@phx.gbl> |
| References | <6a5ceb3f-021d-4acc-b618-ce53530fa2dd@googlegroups.com> <BLU0-SMTP4386E5DFE51C2E3BD49827591B20@phx.gbl> |
| Date | Sun, 12 Jan 2014 01:52:12 +1100 |
| Subject | Re: How to get Mac address of ethernet port? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5331.1389451941.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389451941 news.xs4all.nl 2891 [2001:888:2000:d::a6]:36373 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63706 |
Show key headers only | View raw
On Sun, Jan 12, 2014 at 1:35 AM, Andriy Kornatskyy
<andriy.kornatskyy@live.com> wrote:
> from uuid import getnode as get_mac
> '%012x' % get_mac()
>
Code golf! Put colons in that, with as little code as possible.
# Way too verbose.
import uuid
l=list("%012x"%uuid.getnode())
l[10:10]=l[8:8]=l[6:6]=l[4:4]=l[2:2]=':'
mac = ''.join(l)
# Shorter but not short enough
import uuid
s="%012x"%uuid.getnode()
mac = ':'.join(s[i*2:i*2+2] for i in range(6))
:)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to get Mac address of ethernet port? Sam <lightaiyee@gmail.com> - 2014-01-11 06:26 -0800
Re: How to get Mac address of ethernet port? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2014-01-11 16:35 +0200
Re: How to get Mac address of ethernet port? "James Harris" <james.harris.1@gmail.com> - 2014-01-11 15:54 +0000
Re: How to get Mac address of ethernet port? Roy Smith <roy@panix.com> - 2014-01-11 11:29 -0500
Re: How to get Mac address of ethernet port? Chris Angelico <rosuav@gmail.com> - 2014-01-12 08:40 +1100
Re: How to get Mac address of ethernet port? Roy Smith <roy@panix.com> - 2014-01-11 16:55 -0500
Re: How to get Mac address of ethernet port? Chris Angelico <rosuav@gmail.com> - 2014-01-12 09:08 +1100
Re: How to get Mac address of ethernet port? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-12 11:22 -0500
Re: How to get Mac address of ethernet port? Chris Angelico <rosuav@gmail.com> - 2014-01-12 01:38 +1100
Re: How to get Mac address of ethernet port? Chris Angelico <rosuav@gmail.com> - 2014-01-12 01:52 +1100
Re: How to get Mac address of ethernet port? Skip Montanaro <skip@pobox.com> - 2014-01-11 09:03 -0600
Re: How to get Mac address of ethernet port? Michael Torrie <torriem@gmail.com> - 2014-01-11 09:34 -0700
Re: How to get Mac address of ethernet port? Sam <lightaiyee@gmail.com> - 2014-01-11 17:25 -0800
Re: How to get Mac address of ethernet port? William Ray Wing <wrw@mac.com> - 2014-01-13 10:42 -0500
Re: How to get Mac address of ethernet port? Chris Angelico <rosuav@gmail.com> - 2014-01-14 03:47 +1100
csiph-web