On 05/15/2012 12:10 AM, Thomas Rast wrote:
Michael Haggerty<mhagger@xxxxxxxxxxxx> writes:
9. read_files() doesn't need to return "entries". Since entries is an
array that is only mutated in place, the return value will always be
the same as the "entries" argument (albeit fuller).
(Ab)using an array in this fashion is somewhat iffy. It seems
unavoidable in this case (while still retaining the runtime), but try
not to do it too often, and perhaps name the parameter something that
makes this clear (such as 'out'). Usually changing it to use a
generator function (with 'yield') helps.
If the goal were an ideal Python program, then by all means generators
are the way to go. But since the goal is a prototype for a C program,
then a change to using generators would just have to be undone when
converting to C.
11. It is good form to move the file-level code into a main()
function, then call that from the bottom of the file, something like
this:
def main(args):
....
main(sys.argv[1:])
It's customary to wrap it as
if __name__ == '__main__':
main(sys.argv[1:])
That way your script becomes 'import'-able, which can be handy (if only
for testing).
+1
Michael
--
Michael Haggerty
mhagger@xxxxxxxxxxxx
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html