Browsing Python

Finding The Value Of Pi

Everyone must have heard of Pi, the irrational number that never ends. It goes by this : 3.14159265... I have been learning about Pi since I was in 8th grade. All the time in school, I was curious about to which Pi extends. Now, I know the extend – Infinity :P. I dedicated my precious Christmas vacation for finding the useless value of Pi. Why ? Curiosity. Simply, the curiosity made me want to do this.


Replace Strings in Files With PHP & Python

There are softwares already that helps to replace a string in a file. Suppose, if you’re making a program that requires saving some data in to a file. By ”adding”, the program is actually replacing a word. Let’s see how it’s done in PHP & Python. This is the file where we are going to replace the word : thisWord I got thisWord for making it thatWord replace thisWord already my friend.


Folder Recursion in PHP & Python

A folder has files and sometimes sub directories. If we use the normal function for obtaining contents of a folder, we won’t get the details of the files in the sub directories. In this case, we have to look over into the sub folders and into other sub folders within this sub folder. This looking up of files deep down is called Recursive Folder Searching. By doing this, we can search for a file or do various actions with each files thus recursed.


Word Palindrome Check in PHP & Python

Palindromes are unique words that are read the same forward and backward. We can identify them using out eyes and brain. How about we identify using a simple program in PHP & Python ? PHP <?php $word = strtolower("Malayalam"); $splitted = str_split($word); $reversedWord = ""; $length = strlen($word); for($i = 0; $i < $length; $i++) $reversedWord .= $splitted[$length - $i - 1]; echo $word == $reversedWord ? "It's a palindrome !


Executing Terminal Commands in Python & PHP

Python & PHP are great languages and there are many similarities between them. In this short post, you will learn how to execute terminal commands in PHP & Python. PHP As I said before many times in other posts, there areexec andsystem command to execute commands : exec("firefox ‘’"); Or in the other way : system("firefox ‘’"); Python In Python, there is no exec or system function. But there is a system function in the os nodule.


Infinite loop in PHP & Python

Infinite loops are loops that doesn’t have a defined ending. It will continue to run until the program it’s running in is terminated. Normally an infinite loop is created using while loop and is used for continuity of the same program. In this short tutorial, you will learn how to make an infinite loop in both PHP & Python. PHP There is no need of defining any variables. while(1){ print "


Goodbye AppFog, Hello OpenShift

AppFog and Heroku were one of the most popular PaaS services. But due to the limitations of service many moved out. At first when AppFog came, there were a lot of cool awesome features more than Heroku. For the Free plan AppFog had SSL, Custom Domain and other features. But by the end of February 2013, AppFog removed Custom Domain from free plan. Many customers (including me) got sad, angry and were trying to find another PaaS service. And Here it is, the next Awesome PaaS service – OpenShift.


Create a Simple Browser Using PyGTK, GLADE And MozEmbed

Let’s start creating softwares using Python GTK (PyGTK). Python is the easiest programming language ever and If you are coming from other Programming Languages such as PHP, Here is something that you should understand : Python doesn’t have semi-colons for closing a code. function in PHP is def in Python. Spaces from the starting of a line decides the wrapper of the code. { in PHP is : in Python. There is no closing } in Python.


Loading A Window Created Using GLADE in Python

If you have created a window using Glade and want to display this window on your Python program containing the event handlers of the Window, then you should follow this tutorial. This small code will load the Glade file and displays the window. Note : The Glade Project file format should be GtkBuilder. Now, let’s get down to the code. Create a Python file named in the folder containing the glade file and put in the following contents :


Program to Replace localhost links with website url

If you are working on a project and wants to upload the project to your site, then you have to manually replace all the localhost links with the site url. I created a small Python program that will replace localhost links with your WWW site url. Here is the Python code : #!/usr/bin/python import os indir = ‘/var/www/mysite‘ #!Folder of your localhost site. for root, dirs, filenames in os.walk(indir):  for f in filenames:





This blog was once on WordPress. Now a static site. See source code on



Currently working on projects.