seek operation in python
Larry Hudson
orgnut at yahoo.com
Thu Apr 30 15:38:26 EDT 2015
On 04/30/2015 01:06 AM, Cecil Westerhof wrote:
[snip]
> I wrote a module where I have:
> def get_indexed_message(message_filename, index):
> """
> Get index message from a file, where 0 gets the first message
> """
>
> return open(expanduser(message_filename), 'r').readlines()[index].rstrip()
>
Very minor nit unrelated to the file closing question:
This would be a good place to give index a default value...
def get_indexed_message(message_filename, index=0):
...
-=- Larry -=-
More information about the Python-list
mailing list