Thoughts on new vs traditional idioms

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Tue Mar 2 16:03:44 EST 2004


> From: Peter Otten
> 
> Do you have a class with immutable instances handy where the following
> assertion fails?
> 
> assert immutableObj.__class__(immutableObj) is immutableObj

Jeff's already replied with ImmutableSet, but in any case, user-defined immutable classes are very likely to not have this property.

class Point:

    def __init__(self, point):
        self.x, self.y = point.x, point.y

Most user-defined classes do not implement __new__.

Tim Delaney




More information about the Python-list mailing list