perl chomp equivalent in python?

Samuel A. Falvo II kc5tja at garnet.armored.net
Sat Feb 12 11:17:21 CET 2000


In article <9t9hffh31mp.fsf at mraz.iskon.hr>, Hrvoje Niksic wrote:
>> You may remove the test for line if you know that it is not empty.
>
>Or:
>
>  if line[-1:] == '\n':
>      line = line[:-1]
>
>That works with both empty and non-empty lines.

Why not just use string.strip()?

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



More information about the Python-list mailing list