You are missing an underscore in your __repr__
method name:
def __repr_(self):
# ---------^
Python looks for __repr__
, not __repr_
.
Next, your __str__
method should refer to attributes on self
, not to globals. Perhaps a str.join()
call would be helpful here too:
def __str__(self):
return ''.join([getattr(self, attr) for attr in (
'dst_addr', 'src_addr', 'type', 'payload', 'arptype', 'src_mac_addr',
'src_ip_addr', 'dst_mac_addr', 'dst_ip_addr')])