[PLUG] Python Lists and File Reads
Shahms King
shahms at shahms.com
Fri Jul 15 23:13:21 UTC 2005
Holger Stephan wrote:
> Rich Shepard wrote:
>
>> I had a function working when I specified the input file as "*.py" and
>> imported it as a list. However, I need to be able to use disk files with
>> various names as input, so I changed the code. The function broke (of
>> course!) and I cannot find a web page that gives me the appropriate
>> methods
>> to use.
>
> > ...
>
> Rich: input.read() gives you an array of strings, one for each line in
> the input file. Unless you parse those lines with split() or a regex
> function they are just strings, or character arrays.
input.read() gives you one large string. input.readlines() gives you a
list of strings, one per line.
--
Shahms E. King <shahms at shahms.com>
Multnomah ESD
Public Key:
http://shahms.mesd.k12.or.us/~sking/shahms.asc
Fingerprint:
1612 054B CE92 8770 F1EA AB1B FEAB 3636 45B2 D75B
More information about the PLUG
mailing list