[Python-Dev] Real-world use of Counter

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 5 21:28:49 CET 2014


Ethan Furman wrote:
> Actually, it's asking, "Most other duck-typed methods will still raise a 
> TypeError, but these few don't.  Has that ever been a problem for you?"

I don't think I've *ever* been bothered by getting an
AttributeError instead of a TypeError or vice versa.
Both indicate bugs in my code, and I debug it by looking
at the code and traceback; I don't try to guess the problem
based solely on the exception type.

In this case the code would have to go out of its way
to turn an AttributeError into a TypeError. I don't
think the cost of that is worth whatever small benefit
there might be, if any.

Summary: Looks fine to me as it is.

-- 
Greg


More information about the Python-Dev mailing list