Python and the Principle of Least Astonishment. Written on Saturday, July 9, 2011 When you use something for a long time you will develop some kind of sensing of what goes together and what does not appear to fit the common pattern. The Python community seems to have given this effect a name: if something matches the common patterns it's “pythonic” if it's not, it's deemed “unpythonic”. Most aspects of the language itself are designed to not surprise you if you use them in case there would be more than one possible behavior.
This is what many people refer to the Principle of Least Astonishment). In my mind there are only a handful exceptions to that rule in the language design which I will cover here as well. However if you ask beginners in Python where the language does not behave as expected you will get tons of results. I guess it would make a lot more sense to teach Python to experienced programmers by showing them how the idioms in the language work, more than what control structures there are in Python. Why are you Astonished? Python On Cloudfoundry. For those that haven’t yet had a look Cloudfoundry from VMware is two things, one of which is nice, one of which is very cool indeed: On one hand it’s a platform as a service, allowing you to easily deploy Ruby, Java and Node.js applications to cloudfoundry.com. On the other hand it’s an open source project with all the code on Github allowing you to run the entire stack wherever you like.
I’m pretty interested in the latter. Its API could in theory become a defacto standard for application and service buildouts, in the same way as we’re seeing the EC2 API expand outside AWS for managing infrastructure (and arguably how we’re using Chef and Puppet for managing the things installed on that infrastructure). The really interesting bit is the fact it’s all open source. I’m running vcap on a vagrant managed VirtualBox instance, but you could install it anywhere you like.
I used these chef recipes to get everything installed. Untitled. Spoiler: This post is primarily gonna be an excerpt of my bookmarks collection. That’s because more intelligent men than me have already written great articles on the topic of how to become a great Python programmer. I will focus on four primary topics: Functional programming, performance, testing and code guidelines. When those four aspects merge in one programmer, he or she will gain greatness no matter what.
Functional programming Writing code in an imperative style has become the de facto standard. Imperative programs consist of statements that describe change of state. If you don’t know what I’m talking about, that’s great. Performance There’s so much talk going on about how inefficient these ‘scripting languages’ (Python, Ruby, …) are, that it’s easy to forget that very often it’s the algorithm chosen by the programmer that leads to horrible runtime behaviour.
Testing Testing is probably one the most misjudged topics in computer science these days. Code guidelines. SmileyChris/easy-thumbnails - GitHub.