Hacker News new | past | comments | ask | show | jobs | submit login

It's cool how many of these kludges are fixed in more recent Pythons, especially Python 3 (and its features backported to 2.6 and 2.7):

Q3. Polymorphism, and the lack of sequence and number types -- there are now abstract base classes for Iterable and Number types, etc.

Q6. printf function -- print() is indeed a function in Python 3

Q8. object syntax shortcut -- collections.namedtuple in Py2.6 is similar, acting something like a factory for anonymous classes

Q9. syntax for updating objects -- in recent Pythons, this works: obj.__dict__.update(foo=1, bar=2)

Q10. dictionary with default values -- collections.defaultdict

Q13. abstract base classes -- hilarious, but now there's a decorator in the abc module that does the right thing

Q18. missing queue types -- collections.deque is a good double-ended queue, and the heapq module can turn a list into a heap queue.

You can also see how many of his other wish-list items came true, especially via the itertools module, in his personal 'utils' module:

http://aima.cs.berkeley.edu/python/utils.html




You can also say a_dict.setdefault(key, default) which is like a_dict.get(key, default) but will also do a_dict[key]=default if there does not already exist a value for key.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: