On Mon, 01 Sep 2008 15:25:03 +0200, Hans M�ller wrote: > I'm quite often using this construct: > > for l in open("file", "r"): > do something
> Has someone a better solution ? The most general would be to use rstrip() without arguments: >>> a="some string\r\n" >>> a.rstrip() 'some string' >>> but be careful, because it will also cut whitespaces: >>> a="some string\t \r\n" >>> a.rstrip() 'some string' >>> so maybe you could do this: >>> a.rstrip('\n').rstrip('\r') 'some string\t ' >>> HTH. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/
-- http://mail.python.org/mailman/listinfo/python-list