'<char> in <string>' works, why doesnt '<string> in <string>'?

Peter Hansen peter at engcorp.com
Sun Mar 10 21:19:32 CET 2002


damien morton wrote:
> 
> Check this out:
> 
> ('fox' in 'the quick brown fox')
> ('the quick brown fox'.find('fox') != -1)
> 
> Which of these expressions is clearer, more intuitive and convenient?
> 
> I appreciate your thoughtfull comments, and I agree with you that
> inconsistency should be avoided, but I would assert that this should
> not be at the cost of intuitiveness, convenience and clarity.

Inconsistency is neither intuitive nor clear (after the first 
impression at least).  It may be convenient.  On balance, it's
never worth it.

(Put another way, this question is a matter of opinion, and I'm 
afraid yours is outweighed by the mass of existing Python code
and programmers.  Nothing personal, but don't waste your time.)

-Peter



More information about the Python-list mailing list