While reading <http://users.actcom.co.il/~choo/python/data-structs-python-and-the- wardrobe/data-structures-and-python.html>, I noticed that the example code is not really in Python, I would call this code C in Python :-)

I tried to make the first 3 programs comparing list, array and deque more pythonic <http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0> and example of best practice in general:
 * Don't repeat the same code more then once
 * Avoid non relevant command line parsing code
 * Use Python idioms
 * Avoid timing Python startup time which is not the issue here
 * More useful, a student can run the program once instead of 15 times
 * Show usage of module and function docstings
 * Show how to format output
 * Use only nice readable names
* Show how different collections conform to the same protocol, e.g. append, del

The next 3 programs can be another function in the same program, reusing the formating code.

I attach the code here so people can discuss these changes and improve.


Best Regards,

Nir Soffer

Attachment: test_collection_seq.py
Description: application/text


לענות