MACADDR(3)

✨ MACADDR ✨

okay bestie, so this is the macaddr page from the macaddr 1.0.1 manual (section 3, library functions, you know the vibe πŸ’…) and it's literally all about the packet.link.macaddr MacAddr module. it's short, it's sweet, and it's giving extremely useful. let's get into it πŸ¦‹


🌸 NAME 🌸

packet.link.macaddr β€” the MacAddr module. that's it, that's the whole name, and honestly? iconic πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so what you do is you create an object that represents a MAC address. and how do you feed it that address? two ways, bestie: either as a series of hexadecimal numbers, or using the classic ":" notation. pick your fighter πŸ’…

and here's the cute part β€” it also gives you a whole mechanism for comparing this object with a regular string. so your MacAddr object and your plain old strings can just… chat. vibe check passed ✨


πŸŽ€ CLASSES πŸŽ€

πŸ‘‘ class MacAddr(builtins.str)

a MacAddr address object. it's literally a subclass of builtins.str, so you already know it's got string energy fr fr.

Usage:

from packet.link.macaddr import MacAddr

mac = MacAddr('E4CE8F589FF4')

and here's the slay: the following expressions are equivalent 🫢

mac == 'E4CE8F589FF4'
mac == 'e4ce8f589ff4'
mac == 'e4:ce:8f:58:9f:f4'

like, all three of those hit the same. case? doesn't matter. colons? don't care. that's the whole point, bestie πŸ˜­πŸ’–

πŸ”₯ Methods defined here:

  • __eq__(self, other) β€” compares two MAC addresses and returns True if both are equal. that's it. no notes.
  • __ne__(self, other) β€” compares two MAC addresses and returns False if both are equal. yeah it's the opposite one, we love a matching set πŸ’…

⭐ Static methods defined here:

  • __new__(cls, mac) β€” creates a new instance by converting the input string into a persistent representation of a MAC address. so you hand it a string, it hands you back the glow-up version. main character energy honestly 🌈

πŸ’€ BUGS πŸ’€

no known bugs. we ate and left no crumbs. periodt πŸŽ€


🫢 AUTHOR 🫢

Jorge Mora (mora@netapp.com) β€” thank you for your service, king πŸ‘‘


and that's the whole page! this was pulled from NFStest 3.2, dated 21 March 2023. bye bestie, go compare some MAC addresses, ily πŸ¦‹πŸ’œ