How to get the local mac address?

Daniel Crespo dcrespo at gmail.com
Wed Dec 14 17:14:19 EST 2005


Hi, Scott,

Thanks for your answer

>> Hi, I tried: ...
>>     # Convert binary data into a string.
>>     macaddr = ''
>>     for intval in struct.unpack('BBBBBB', buffer):
>>         if intval > 15:
>>             replacestr = '0x'
>>         else:
>>             replacestr = 'x'
>>         macaddr = ''.join([macaddr, hex(intval).replace(replacestr, '')])
>
>
>Replace the above by:
>       return '%02X' * 6 % struct.unpack('BBBBBB', buffer)

Replace all the above? I mean all this:

     # Convert binary data into a string.
     macaddr = ''
     for intval in struct.unpack('BBBBBB', buffer):
         if intval > 15:
             replacestr = '0x'
         else:
             replacestr = 'x'
         macaddr = ''.join([macaddr, hex(intval).replace(replacestr,
'')])

?

>(doesn't help with win98, though)

Sorry, but I don't understand... I would like it to get running on
Win98. I know I have to change some code here, but don't know what :(




More information about the Python-list mailing list