[Tutor] file I/O

steve lonetwin@yahoo.com
Thu, 12 Jul 2001 11:45:06 +0530


Hi all,
=09I've been meaning to ask this question for a long time now,
I've always seen ppl do file i/o, especially file read using an open()=20
followed by a loop of readline(), stripping the '\n' at the end....
  I discovered fileinput (the module) quite early on when I started learn=
ing=20
python....so I always do things like

Python 2.1 (#3, Jun 25 2001, 13:39:27)=20
[GCC 2.95.3 19991030 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import fileinput
>>> p =3D [ line.strip() for line in fileinput.input("myfile.txt") ]

=09What bothers me is that I don't see enough ppl do that, an' I wonder i=
s it=20
b'cos it is some kinda *Bad thing* ....could n e one comment on this ???

--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/    \#########/    \=09
|\     \#######/     /=09
||\____/#######\____/|=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=09
Debug is human, de-fix divine.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D