two ideoms at one blow: line-reading and regexp-matching
Gustavo Cordova
gcordova at hebmex.com
Wed Feb 20 10:46:48 EST 2002
>
> Simon Brunning writes:
> > for line in file:
> > line.whatever()
>
> Cool. Good reason to upgrade to 2.2.
>
> > > matched = re.match(r'egexp(.*)', line)
> > > if matched:
> > > print matched.group(1)
> >
> > Assignments and expressions are different things in Python...
>
> Indeed, and that's a good thing. But I'm proposing an alternate
> syntax for the if statement, specifically:
> "if" <variable> "=" <expression":.
>
But you impact legibility:
mo = findSomething.search(someString)
while mo:
....
....
mo = findSomething.search(someString)
is much more understandable than:
while mo = findSomething.search(someString):
....
....
mo = findSomething.search(someString)
because *that* can be confused with *this*
while flag == object.method(something):
....
....
and confusion ensues.
no?
I'd sincerely prefere the more readable alternative.
-gustavo
More information about the Python-list
mailing list