News for hackers. Stuff that matters.
Re:Why did Microsoft invest so much in F#? by rlmw on Monday November 08, 2010 @05:05PM (#1884222)
Upvoted because that's good code reuse in the scenario that you only want to store a default value, and I can see why you replied to the commenter with it. It doesn't necessarily work so well in the scenario where you want to perform some operation if there isn't a value. Or if default needs to be computed. I'm assuming that the idiomatic way of doing this in python would be:

try: value = dict['foo'] except KeyNotFound: value = do_something_interesting() dict['foo'] = value

If you could pass a function in as a default of course this point is moot!

Re:Why did Microsoft invest so much in F#? by popleft on Monday November 08, 2010 @05:18PM (#1884268)
See collections.defaultdict in the standard library -- http://docs.python.org/library/collections.html#collections....
Re:Why did Microsoft invest so much in F#? by masklinn on Monday November 08, 2010 @05:43PM (#1884362)
> It doesn't necessarily work so well in the scenario where you want to perform some operation if there isn't a value.

No, but that's not what the example he replied to does.