AgileDevelopmentForTheWeb

From SPA Wiki

Jump to: navigation, search

Exercise Solutions

You can find these at http://www.comp.leeds.ac.uk/nde/SPA/.

Thoughts on Python & Django

Tutees generally liked Python's syntax. One negative point raised during the session concerned a lack of consistency with regard to object orientation. Some operations are methods on objects, whereas others (e.g., len) are built-in functions.

Another point of discussion was Python's dictionary data type. A couple of people were surprised that the keys of a dictionary are not ordered by default. I noted at the time that this could be solved by subclassing dict, and here is an example of this approach:

 class SortedDict(dict):
     def keys(self):
         key_list = super(SortedDict, self).keys()
         return sorted(key_list)
     def items(self):
         item_list = super(SortedDict, self).items()
         return sorted(item_list)
     def values(self):
         return [ value for (key, value) in self.items() ]

Tutees: please add any other comments or observations below.