Simon Willison posts an interesting example of how to code the equivalent of switch statement in Python.
The example is really neat and syntactly cleaner than the example of a more usual switch statement, however anyone coming across that code for first time would most likely be mystifed by it. Not mystified in the same way as having to decode read-only Perl which uses all the tricks in one line, but mystified in that it is so simple but uses constructs like lambda statements that you don't really need to know to understand most of the Python code you will ever encounter.
You can learn all the Java syntax that you will ever use in a couple of days however to master all of the Python syntax takes time. Most people don't use it all but Simon's example and a lot of the code in Dive into Python is a great example of how you can write concise Python using all the neat features of the language that beginners can easily overlook.
Posted by stuartcw at May 7, 2004 09:01 PMI dunno - I remember being thrown a bit when I first encountered inner classes in Java. Stuff like switch replacement dictionaries looks a bit gnarly at first, but I find it actually makes sense provided you understand Python's rules - it's consistent with the rest of the language. I've certainly seen much more unreadable tricks used in Perl and C.
It says something for Python that you really have to go out of your way to write code that's hard to read ;)
Posted by: Simon Willison at May 8, 2004 11:15 AM