What I don’t like about Python
lukepalmer.wordpress.com
lukepalmer.wordpress.com
Here's his examples rewritten in Python (Python is not Ruby despite that both are nice languages):
with atomicio_handler(afile) as handle:
handle.write("foo")
if blah:
raise Exception, "baz"
handle.write("bar")
with atomicio_handler(afile) as fh1:
with atomicio_handler(anotherfile) as fh2:
...If this is true, I am apparently quite the programming badass, and so is anyone who has conquered the "callback function" section of your C textbook of choice. In some cases, I wouldn't know what to do without them, and I enjoy the fact that Python makes it seem very natural to be passing them around.
Not me. Real rants are more fun to read. cf http://linuxhaters.blogspot.com/2009/01/river-of-fail.html
Yossi already has what's basically a C++ hater's blog.
I'd like to see these for every popular language and platform.
So why did 26 people vote this up? There's almost no meat to it at all.
The actual meat, for me, is thinking about how one goal interferes with another. Not news, but examples are always welcome.
Thanks for answering my question even though I didn't ask it well.
Author's perceived deficiencies in language were actually deficiencies in author's knowledge of that language.
Humbleness, you proly need more of that.
What do I mean? Python has two main built-in collection types, list and dict. If you have a list you can use "in" to ask whether the list contains a value:
>>> a = ['a','b','c']
>>> 'a' in a
True
>>> 'zzz' in a
False
But if you're using a dict, "in" tells you whether the dict's keys contains a value (not the dict's value). >>> d = {'x':'a', 'y':'b'}
>>> 'a' in d
False
>>> 'x' in d
True
To enumerate over a dict's key-value pairs, you use .items(): >>> d.items()
[('y', 'b'), ('x', 'a')]
But to enumerate over the key-value pairs in a list, you have to use enumerate(): >>> list(enumerate(a))
[(0, 'a'), (1, 'b'), (2, 'c')]And tuples.
> To enumerate over a dict's key-value pairs, you use .items():
You can also use enumerate.
> But to enumerate over the key-value pairs in a list, you have to use enumerate():
Just like you can with lists.
Python's collection operations do the right thing on collection data types. The fact that those data types also have type-specific operations merely means that those data types have some properties that are not common to all collection types, which is pretty much the reason why they exist.
[And yes, I fumble-fingered "Just like you can with dicts." above.]
At least he didn't call anyone out for VB...thems fightin' words.
Zing!