On 2010-02-17 11:24:43 -0500, bearophile <[email protected]> said:
In Python there are no chars, there are just strings, a char is a string of length 1, so the __contains__ performs a substring search (with many optimizations, so if you look for a substring of length 1 it's faster, etc).
Actually that's an interesting topic. You're suggesting that 'in' for arrays could search not only for elements but also for subarrays?
The interesting part is that the syntax is very natural. The less interesting part is that it's slower and slightly different from 'in' in associative arrays. I'm on the fence.
-- Michel Fortin [email protected] http://michelf.com/
