perl to python

Andrew Dalke adalke at mindspring.com
Thu May 13 02:12:27 EDT 2004


Scott Schwartz:
> 1) Python throws an error if you have less than three fields,
> requiring more typing to get the same effect.

The spec didn't say how to handle improperly formatted data.
Suppose the code is supposed to complain and stop at that
point - how much code would you need for awk to do the
extra check?

> 2) Python generators on stdin behave strangely.  For one thing,
> they're not properly line buffered, so you don't get any lines until
> eof.  But then, eof is handled wrongly, and the loop doesn't exit.

There's a command-line flag to make stdin/stdout be unbuffered.
Try your test again with 'python -u'.

> 3) There is no efficient RS equivalent, in case you need to read
> paragraphs.

Again, not part of the spec.  ;)

                    Andrew
                    dalke at dalkescientific.com





More information about the Python-list mailing list