| The presentation incorrectly identified Python dictionaries as “lists”. It also identified actual Python lists as lists. The presentation states that tuples are “immutable lists“ and that they ”should be homogeneous, but [this is] not enforced“. I disagree: tuples are meant to act as “records“ (as in a database or other set of data), which are neither lists nor homogeneous. The presentation brought up multiple times filter and map. An article by Guido in 2005 [1] argued that these tools should be cut from Python 3. While they still exist, I am under the impression it is considered more Pythonic to use list comprehensions in the place of filter and map, as stated in the article. Python not having define_method is misleading. One can define a method of a class as one would any attribute of the class [2]. However, it is far easier to dynamically define a method in Ruby than in Python, because lexical scoping is inherent to a Ruby block but not a Python loop. Python not having method_missing is wrong. One can simply override __getattr__ and return the appropriate function [3]. [1]: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 [2]: http://ideone.com/njXDzO [3]: http://ideone.com/EB9MQ8 |
Indeed, hence `namedtuple` (named tuples extend tuples). The author got it exactly backwards: tuples are generally heterogenous, the (rare) cases of homogenous tuples are reflexive short lists and hope of a slightly cheaper creation cost.