crimes in Python

Kragen Sitaker kragen at dnaco.net
Wed Mar 8 20:38:16 EST 2000


In article <slrn8cd3fr.2c5.scarblac-spamtrap at flits104-37.flits.rug.nl>,
Remco Gerlich <scarblac-rt at pino.selwerd.nl> wrote:
>It's a very common idiom in Python. I try to keep the breaks near the 
>while 1:. That seems to be enough.

If it's a common idiom, I guess it must be OK; anyway, other people
will be able to read it.  :)

>> >My intuition is that there should be a clean way without regexpen. But I
>> >can't think of any right now. If this works, keep it :-)
>> 
>> Well, you really do need a state machine with several states; regexps
>> are a compact and (theoretically) understandable way to write those.
>
>True. I must say, I've *never* need them in Python yet, so I couldn't
>actually see what was happening exactly :)

Well, the lines are things like this:

2911.02,"ROBBERY - FORCE, THR",foo,bar,baz

And I want something like ['2911.02', 'ROBBERY - FORCE, THR', 'foo',
'bar', 'baz'] as a result.  Note that the comma in the robbery field
doesn't split the field.

What I actually wrote left the quotes on, which isn't worth taking the
time to fix.

(Note to self: try not to use regexen in Python unless you need them.
Nobody will understand you.)
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either.  :)



More information about the Python-list mailing list