Random MAC generator error
denismfmcmahon at gmail.com
Sat Sep 12 22:31:12 CEST 2015
On Sun, 13 Sep 2015 00:50:24 +0530, Robert Clove wrote:
> import random #
> global mac1
> def randomMAC():
> mac = [ 0x00, 0x16, 0x3e,
> random.randint(0x00, 0x7f), random.randint(0x00, 0xff),
> random.randint(0x00, 0xff) ]
> return ':'.join(map(lambda x: "%02x" % x, mac))
> print randomMAC()
> for x in range(1,11):
> mac1 = randomMAC()
> print mac1
> I got the following random mac generator script from the net (simple
> google search)
> i want to use random mac in one of mine script.What i need is
> mac1=randomMAC() should give mac value to mac1 that i use in a function
> and this runs in a loop.
And you haven't told us what the "error" you're posting about is?
When I ran the code I got the following result:
Observation: No point in declaring mac1 as global in the global scope.
Is it possible that you've tried to run python 2.x code on python 3.x and
hit an error due to 'print x' -> 'print(x)'?
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list