Larry Bates a écrit : (snip) > def d(x): > if isinstance(x, basestring): > # > # Code here for string > # > elif isinstance(x, int): > # > # Code here for int > # > elif isinstance(x, float): > # > # Code here for string > # > else: > raise ValueError
As a side note : While there are a few corner cases where this is hardly avoidable (and yet I'd rather test on interface, not on concrete type), this kind of cose is exactly what OO polymorphic dispatch is supposed to avoid (no, don't tell me: I know you can't easily add methods to most builtin types). -- http://mail.python.org/mailman/listinfo/python-list