Understanding Python “Property”

1 mainI was tinkering with Python the other day when I encountered the “property” keyword. I had seen it many times before and I sort of knew what it does, but I never really had a chance to dig deep into it. As it turns out, “property” in Python is very useful when you are designing large systems. People who come from the world of object oriented programming will appreciate it right away. It’s a nifty little concept which makes the life of a programmer much simpler. So what is it all about? Before we jump directly into what it is, let’s get some perspective as to why we would need it in the first place.   Continue reading “Understanding Python “Property””

How To Install PIL On Ubuntu

picLet’s say you want to play around with images in Python. To do that, we need a Python package that can handle all the image manipulation. Python Imaging Library (PIL) is one of most popular libraries that is used to process the image data. Actually, people use Pillow now, which is a modern repackaged version of PIL. It has a lot of nice functionalities and it works well. Let’s see how you can install PIL on 64-bit Ubuntu 12.04.   Continue reading “How To Install PIL On Ubuntu”

Display Caller Of The Current Function In Python

python-logoIf you have spent enough time coding, then you know where I am going with this. As the code gets bigger, debugging gets trickier. Keeping track of everything becomes difficult, especially when you collaborate with others and your functions are being called by someone else’s functions. A lot of times, you may want see where your function is being called so that you can pinpoint where things went wrong. Luckily, Python has a neat way of doing it. You can get a list of all the locations where your function is being called, along with the line numbers.   Continue reading “Display Caller Of The Current Function In Python”

How To Convert An Existing Django Project To Eclipse Project

mainSo you have a Django project and you want to use Eclipse IDE to modify and control it. When I say “existing Django project”, I mean a Django project created without using Eclipse. If you are not sure how to use Eclipse to manage your Python project, you can check out this blog post. You basically need to install PyDev and configure the Python path for Eclipse. Once you install everything, you should be able to see PyDev listed when you start a new Eclipse project.   Continue reading “How To Convert An Existing Django Project To Eclipse Project”

How To Build A Web Crawler?

webI was reading an article the other day and I came across the term “web crawler”. The context in which it was used got me a little curious about the design of a web crawler. A web crawler is a simple program that scans or “crawls” through web pages to create an index of the data it’s looking for. There are several uses for the program, perhaps the most popular being search engines using it to provide web surfers with relevant websites. Google has perfected the art of crawling over the years! A web crawler can pretty much be used by anyone who is trying to search for information on the Internet in an organized manner. It is referred to by different names like web spider, bot, indexer etc. Anyway, that article got me thinking about building a web crawler. I just wanted to fiddle with it and see how much time it will take to get something working on my machine. It turned out to be quite easy!   Continue reading “How To Build A Web Crawler?”

Python Development In Eclipse

As your code gets bigger, effective code management becomes an integral part of your project. This post is about setting up Python development environment in Eclipse. Most of the Python developers will already be aware of this. For those of you who are not, read on. Eclipse is an IDE which supports many different languages. It has plugins for various different frameworks as well. We will discuss about how we can set up everything from scratch. Once you set everything up, you will be able to run and debug you Python code easily. It provides many different options and it has a nice UI too.   Continue reading “Python Development In Eclipse”

Exploring The Lesser Known Features Of Python – Part II

As it is evident from the title, this is the second part in the Python exploration series. You can find the first part here. I have discussed a few lesser known but very useful features of Python. There were too many features, so I didn’t put everything in a single blog post. I will continue discussing more features in this post. I will keep adding more as and when I discover more things about Python.   Continue reading “Exploring The Lesser Known Features Of Python – Part II”

Exploring The Lesser Known Features Of Python – Part I

I have been fiddling with Python for some time now and I have to tell you, it just keeps getting better and better! Every time I interact with Python, I stumble across something new. There are so many things you can do with it. It is very well documented and most of the material is available out there. There are some of the lesser known features which are very useful, but you don’t see them often. There are quite a few and I have split it into two parts. You can find the second part here. I have listed the first few here:   Continue reading “Exploring The Lesser Known Features Of Python – Part I”

Essential Python Tools: virtualenv and pip

A wise man once said ‘Necessity is the mother of invention’. But I think the real mother of invention is laziness. If you are lazy enough, you will find an easier way to do a particular thing. In order to solve large problems elegantly, we need to use tools that solve smaller sub-problems very well. To the coder in you, yes, it’s a bit like dynamic programming! If you have fiddled with Python, you would have definitely come across many different libraries and packages. Sometimes, you wish that you had different machines for different libraries because the requirements differ from one thing to another. There should be an easier way to manage different environments and packages right?   Continue reading “Essential Python Tools: virtualenv and pip”