On 11/18/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > (Although I will point out > that most protocols for things like len() *do* involve checks for special > methods by name, and the check for iterability is typically a non-destructive > call to iter(x), rather than a destructive one to x.next()).
Ouch?! I would never check for iterability explicitly. I would just require it, as Greg Ewing says. iter() could be fairly expensive, depending on what is being iterated over. Maybe this is unique to iterators and iterators are a bad example? I don't feel as strongly about this when testing e.g. for string-ness, file-ness or list-ness. While I tend to dislike those tests too, they are sometimes inevitable when we want to overload an API. Especially file/string is often overloaded, and I see no big problem with this (I do dislike overloading list/dict, or string/list-of-strings). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com