Tornado – Escape – Json

Tornado web server exports methods for escape/unescape html, xml, Json among others. This blog discusses about encoding and decoding JSON format. Tornado has the following methods: tornado.escape.json_encode(value) - JSON'ify the Python object passed to it as argument tornado.escape.json_decode(value) - Converts the JSON string into Python Object Here's a usage example: In this example, 1. … Continue reading Tornado – Escape – Json

Tornado – Templates – Run time and Cached

Website development often calls for reuse of pages. For instance, when you open your Citibank account after login the welcome page you see is same what other bank customers see but its customized with your name and settings. Do you think Citi creates so many web pages for all its customers? Well, they use, what's … Continue reading Tornado – Templates – Run time and Cached

5 Ways of Fibonacci in Python

After learning so much about development in Python, I thought this article would be interesting for readers and to myself... This is about 5 different ways of calculating Fibonacci numbers in Python [sourcecode language="python"] ## Example 1: Using looping technique def fib(n): a,b = 1,1 for i in range(n-1): a,b = b,a+b return a print … Continue reading 5 Ways of Fibonacci in Python

Performance for testing memberships: list vs tuples vs sets

Sets in Python are often used for two purposes: 1. Removing the duplicate entries in a collection 2. For membership testing. By membership, here we mean to find existence of element in a collection The focus of this post is to evaluate performance of list, tuple and set data structures with respect to each other … Continue reading Performance for testing memberships: list vs tuples vs sets

Python Decorators

Let's start with something simple..What is a decorator? According to, "A decorator is the name used for a software design pattern. Decorators dynamically alter the functionality of a function, method, or class without having to directly use subclasses or change the source code of the function being decorated" A classic example tat I can … Continue reading Python Decorators