News for hackers. Stuff that matters.
Re:Ruby is beautiful (but I'm moving to Python) by orangecat on Sunday November 28, 2010 @02:50PM (#1948088)
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

There are no comments on this comment yet.