NEWBIE: Tokenize command output

bruno at modulix onurb at xiludom.gro
Fri May 12 12:23:52 EDT 2006


Duncan Booth wrote:
> bruno at modulix wrote:
> 
> 
>>>Otherwise, just to be informed, what advantage does rstrip() have over
>>>[:-1] (if the two cases are considered uneventfully the same)?
>>
>>1/ if your line doesn't end with a newline, line[:-1] will still remove
>>the last caracter.
>>
> 
> In particular, if the last line of the file doesn't end with a newline then 
> the last line you read won't have a newline to be stripped.

Thanks - I knew there was a corner case for files, but couldn't remember
it exactly.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list