"sins" (aka, acknowledged language problems)
Aahz Maruch
aahz at netcom.com
Fri Dec 17 09:57:26 EST 1999
More information about the Python-list mailing list
Fri Dec 17 09:57:26 EST 1999
- Previous message (by thread): "sins" (aka, acknowledged language problems)
- Next message (by thread): "sins" (aka, acknowledged language problems)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <6D8A17398E28D3119F860090274DD7DB4B3D51 at pces.cadlab.it>, Alex Martelli <Alex.Martelli at think3.com> wrote: > >Would this also apply, to a weaker but broader extent, to the lack of >assigning-operators, an "expression" kind of assignment, increment and >decrement in particolar, or other issues of the expression/statement >split? Yes and no. I am, on the whole, very happy with the way Python absolutely does not allow assignments in conditions. Increment and decrement would be useful, but not if it would break the expression/statement split. I think you'll find that very few long-term Pythonistas see this as an issue. > while 1: > line = inp.readline() > if not line: > break > oup.write(regex.sub(repl,line)) > >and wonder that *FOUR*-count-em lines of this function, fully half of >it, are devoted to the trivial, frequent, repetitive task of looping >over input lines, reading each one, bailing out when done. Yeah, I >know I could have written the break on the same line as the if, but >that's considered bad Python style:_) > >But why can't I change those 4 lines to, say: > while line := inp.readline(): >using the suggested ":=" operator that I've seen mentioned now and >then? Or, maybe even better, "while line from inp.readline()" or other >variants suggested in the past. Because the current consensus is that eventually you will be able to write for line in inp.readline(): In fact, if you're willing to take a chance on memory usage, you can already do for line in inp.readlines(): Fredrik already showed you another module that you can use; finally, you can try using QIO to make up for Python's deficiencies in line-by-line file IO. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 14 days and counting!
- Previous message (by thread): "sins" (aka, acknowledged language problems)
- Next message (by thread): "sins" (aka, acknowledged language problems)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list