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

damien morton morton at dennisinter.com
Mon Mar 11 00:28:55 EST 2002


Peter Hansen <peter at engcorp.com> wrote in message news:<3C8BBFD4.A29A69F1 at engcorp.com>...
> 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?

> (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.)


The existing mass of python code would be unchanged. The only issue
that might occur is that something that is now an error, would not be.

It remains to be seen whether or not the mass of python programmers
are opposed.

No-one has taken me up on my question about what circumstances one
would want "'fox' in 'the quick brown fox'" to throw an exception,
rather than return a result.

[On a tangent... we now have proposals for a boolean type to be added
to Python, does this presage the addition of a char type also?]



More information about the Python-list mailing list