4 ms·
There are quirks in every languages - python obviously included. And please, don't forget that you're using a very old version of the Javascript language. It's
by d0m 14y ago
There are quirks in every languages - python obviously included. And please, don't forget that you're using a very old version of the Javascript language. It's a little bit like if I'm arguing about the errors and quirks of Python 1.5. Languages evolve and learn from their mistakes. Unfortunately, old browsers are stuck with old javascript versions. Some people have to write code in java 1.4 or python 1.5, they aren't People who are good at [python or java] like [python or java] because it makes them special.
And that being said, most people coming from [name your favorite language] believe that Javascript works the same way as their language. It's a different language and require a different knowledge. In fact, javascript' similarity to algol might be one of the biggest problem of the language. Have you tried working with C++ without learning the language?
And here are some Python cool "features":
def foo(x=[]):
x.append(2)
print x
foo()
foo()
Guess x? To take your term "You lose".
print 3/2
What's the result? If you answered 1.5, sorry, you're wrong. We're using Python <2.2 here, and it gives 1.
Here's another one, what does it do:
for i in range(10): print "*",
print
Is it ""? Sorry, a comma at the end doesn't include a "\n" but automatically insert a space.
Anyhow, have fun here: http://stackoverflow.com/questions/530530/python-2-x-gotchas-and-landmines http://stackoverflow.com/questions/530530/python-2-x-gotchas...
- w0utert 14y agoNo language is perfect, but if those are the worst examples you can come up with for Python, there really is no comparison with the insane JavaScript WTF's I've seen. Default list/dictionary arguments are plain evil in Python, no disagreeing there. I've been bitten by something like the following before, which is similar to your snippet: x = y = [] x.append(2) print x print y As for your other examples: except for Pascal/Delphi, I have never used a language that has separate division operators for floats and integers, so at least for me it's only natural that 3/2 == 1, how else would I do integer division? The print example is just very weak, I can hardly even call it a WTF. Yes it's a little odd, but you're not going to hit weird runtime bugs like when you are comparing things in JavaScript, for example. I'm frankly very surprised by the almost complete absence of real Python WTF's in the Stack Overflow discussion you linked, I would have expected more. If anything, it actually shows how clean and predictable Python is.
- d0m 14y agoMaybe I wasn't clear. The gotcha with 3/2 == 1 isn't that it's giving 1, it's that the behavior changes depending of the version of python.