Remove redundant file.close calls and variable assignment
authorMike Looijmans <milo-software@users.sourceforge.net>
Sat, 16 Aug 2014 14:45:46 +0000 (16:45 +0200)
committerMike Looijmans <milo-software@users.sourceforge.net>
Sat, 16 Aug 2014 15:10:05 +0000 (17:10 +0200)
commit6cc21c1a48f08cdb7a1f6ad3306d4e704d58738d
treec4c17d61329005f9491726a590b3037b1f9878a3
parent997aded41aad08c9177b364c1209b223e58c67c2
Remove redundant file.close calls and variable assignment

Calling close() on files is redundant, files will automatically close when
going out of scope. Something like:

f = open(name,"r")
value = int(f.readline())
f.close()

is just a waste of resources, writing:

value = int(open(name,"r").readline())

is more efficient because it doesn't need to store and retrieve objects from
the namespace.

A file is an iterator, so instead of file.readlines() one can usually use the
file itself, instead of first reading it into a list. This also saves on
resources.
lib/python/Components/FanControl.py
lib/python/Components/Keyboard.py
lib/python/Components/Sensors.py
lib/python/Components/config.py