goodmaio.blogg.se

Convert mac address to colon win8
Convert mac address to colon win8











convert mac address to colon win8

If I was writing this, however, I would probably do it in just a couple of lines, as you know exactly how the input and output strings are going to be formatted: def mac_conv(mac, sep='-'):

convert mac address to colon win8

You can actually eliminate that usage of the variable all together: #join groups into a single MAC I would also avoid reusing variables, especially if its a function argument ( mac). #Open file with MAC addresses and convert them Return '.'.join(''.join(group) for group in groups)įirst of all, you should be using return rather than print to get a value out of a function, otherwise you'll have problems when you try to expand the program. This can result in: def mac_conv(mac, sep='-'): Other than the above function, you don't need to use f.readlines() you can just use f.

convert mac address to colon win8

I'd then join the last three lines into one.Īs return and '.'.join are easy to understand in a single one-liner.

  • Perform a list comprehension to join the sliced segments together.
  • Slice segments into a three item list.
  • To do this I would base my algorithm around the use of a list comprehension. The only thing I'd change is to reduce the amount of lines.













    Convert mac address to colon win8