[Tutor] <> and chomp

David Rock david at graniteweb.com
Thu Sep 14 18:25:04 CEST 2006


* William Allison <allison.william at comcast.net> [2006-09-14 12:14]:
> Hi,
> I'm new to programming and started with Perl but have been reading a lot
> of good things about Python.  Thought I would switch before I have too
> much time invested in Perl.
> Anyway, my question is, is there something in Python similar to the
> diamond operator and chomp from Perl?  I'm trying to read in from a file
> line by line and get rid of the '\n' at the end of each line.

fileinput() is similar to <>
http://docs.python.org/lib/module-fileinput.html

rstrip() is similar to chomp
http://docs.python.org/lib/string-methods.html#l2h-201

These aren't exact matches, but they are close.

-- 
David Rock
david at graniteweb.com


More information about the Tutor mailing list