[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Perl chop equivalent in Python?
From: "Fredrik Lundh" <effbot () telia ! com>
Date: 2000-05-31 19:13:01
[Download RAW message or body]
pem@my-deja.com> wrote:
> Is there an equivalent command to chop (the perl command) in Python? If
> not, is there some easy way to use existing commands to do this simple
> task? I need to do it frequently and would like to have a readily
> available command that does not require much programming. Thanks in
> advance.
www.python.org => search => newsgroup search for
"chop" => a whole bunch of hits, including this one by
Fran‡ois Pinard:
http://www.deja.com/=dnc/getdoc.xp?AN=583863832
...
To chop (even if line is truly empty):
line = line[:-1]
To chomp:
if line and line[-1] == '\n':
line = line[:-1]
...
</F>
--
http://www.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic