July 30th, 2003

pixelated

(no subject)

Ah, Python's syntax just got a little bit nicer.

I used to dislike having to write things like:
if line.find("<!-- NAME:") >= 0:

Because it looked ugly, and looking ugly isn't what Python code is meant to be. <troll>If I wanted my code to look ugly, I'd use Perl</troll>.

Now in Python 2.3:
>>> foo='bc'
>>> bar='abcd'
>>> foo in bar
True
>>> 

Actually, the jibe at Perl is a little unfair in this case. The reason the old find method seemed so ugly to me was mostly in comparison to if(/foo/) in Perl. In retrospect missing the if substr in string: was a something of a wart given the other uses of the "in" infix operator.