On Mon, 2014-01-20 at 10:41 +0000, Oscar Benjamin wrote:
[…]
> f = open('myfile.txt')
> for line in f:
> print(line.upper())
> f.close()
I suggest we even see this as not good code due to the possibility of
I/O exceptions:
with open('myfile.txt') as f:
for line in f:
print(line.upper())
should, I argue, be the canonical idiom in modern Python.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:[email protected]
41 Buckmaster Road m: +44 7770 465 077 xmpp: [email protected]
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor