[Tutor] file enigma

Tim Golden mail at timgolden.me.uk
Thu Jun 11 13:03:24 CEST 2009


spir wrote:
> Thank you, Tim, this really answers my question.

Glad to be of help :)

> 
> * I intended to write a helper func "filetext(filename)" to 
> open/read/close/return (or equivalent using the with idiom).

This is one of those tricky things in Python: when the "raw" code
is possibly one line long, and at most two (for Python 2.5+), it's
only marginally worth creating a function for it unless you've got
some substantial extra functionality. Ultimately it's a matter for
personal taste / project needs.

TJG



More information about the Tutor mailing list