Viewing posts by christian_abbott
Lea Verou has a wonderful talk about various techniques we can use to create a pie chart purely in HTML/CSS. The techniques are clever and interesting, but pie charts are a little boring. So let's modify one of her ideas and create Pacman instead.
You and a friend are imprisoned but have a chance for freedom. To earn it, you must walk alone into a separate room where a chess board is laid out with a coin per square randomly showing heads or tails. You are shown a particular square on the chess board, and are then allowed to touch one coin to flip it. Then you must leave without making any contact with your friend. Your friend enters the room and must pick the square which was pointed out to you. You and your friend may discuss a strategy before you enter the room.
The built-in iter() method in Python 2.2 and later hides a neat trick which is not well-known. Typically iter() is used to return an iterator from an iterable object:
The Python programming language has some useful flexibility which it can take a while to discover. One such example is exceptions. As programmers, we want as much relevant information as we can get when something goes unexpectedly wrong in our programs. When an unhandled exception bubbles up, Python's default behavior is to print a stack trace, the type of error, and an error description. This is printed to sys.stderr (i.e., the console window, typically), like this:
Followers, you may be familiar with the scenario where you dance with one leader, and receive feedback that your embrace is too firm, but when you dance with another leader, the same embrace is too light. So, which is it?