Re: Memory usage in Python?
Thats exactly what I was recommending, I just wanted him to search a bit for himself . I however would consider backing that operator up with some type checking, or at least exception checking (just following the etafftp pattern), cause otherwise the whole thing would crash down in flames if you throw something in there that doesn't have a name attribute, and since you put the self.name == other.name evaluation first, it will even crash when comparing to strings. I'd consider something like that in Python 3:
def __eq__(self, other):
if isinstance(other, str):
return self.name == other
elif isinstance(other, map):
return self.name == other.name
return NotImplemented
Or like the following (if you like to follow etafftp):
def __eq__(self, other):
try:
return self.name == other.name
except AttributeError:
return self.name == other
You'd still need to either do more checking that way, or you could throw almost anything in there and it will simply compare it to your map name and see if it matches .
Best Regards.
Hijacker
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector