Newbie asks: How to translate this line of C to Py

Fredrik Lundh fredrik at pythonware.com
Tue Jul 10 02:07:10 EDT 2001


Steve S.L. Wong wrote:

> while (command = strtok(line_ptr,";"),line_ptr=0,command) {
> }

ouch.  that's ugly.  ever heard of for-loops?  and did you miss
the "Never use this function" sentence in your C library manual? ;-)

anyway, this is a pretty good emulation:

for command in line.split(";"):
    ...

</F>





More information about the Python-list mailing list