2 ms·
Sure, you can do most of Ruby's wacky tricks in Python, it's just not usually recommended: >>> class Foo: ... def __init__(self, name): ... s
by orangecat 16y ago
Sure, you can do most of Ruby's wacky tricks in Python, it's just not usually recommended:
>>> class Foo:
... def __init__(self, name):
... self.name=name
>>> a1 = Foo('Alice')
>>> a2 = Foo('Alice')
>>> a1==a2
False
>>> Foo.__eq__ = lambda self,other: self.name==other.name
>>> a1==a2
True