[Python-3000] interfaces
Antoine Pitrou
solipsis at pitrou.net
Sun Nov 19 20:18:14 CET 2006
Le dimanche 19 novembre 2006 à 12:44 -0500, George Sakkis a écrit :
> I understand this is not the point you're trying to make, but in such
> cases I usually prefer to make @decorator be equivalent to
> @decorator() by something like:
I could do that, but it's not very clean. Also it doesn't invalidate my
point, since what callable() does is precisely to check that the
parameter conforms to a given interface (instead of explicitly testing
for the underlying implementation e.g. __call__).
I'm not an interface fan at all. Simply, in some cases, it would be
cleaner to check an object implements, or claims to implement, a
conventional interface (which might not even involve any syntactic
checks about the presence of a method), rather than testing for a
specific implementation trait in the hope that it's both necessary and
sufficient.
More information about the Python-3000
mailing list