|
|
|
|
|
by SmirkingRevenge
2910 days ago
|
|
This is the kind of thing I might turn into a simple function with short circuiting returns. I suppose the new syntax is just as readable, but I kind of like it this way a bit better. def get_reductor_value(cls, x):
reductor = dispatch_table.get(cls)
if reductor:
return reductor(x)
reductor = getattr(x, "__reduce_ex__", None)
if reductor:
return reductor(4)
reductor = getattr(x, "__reduce__", None)
if reductor:
return reductor()
raise Error("un(shallow)copyable object of type %s" % cls)
|
|