Tag Archives: python

Creating Dictonaries from Arrays / Lists

PHP: In PHP, we can create a new associative array or dictionary by using the array_combine() function. Just feed two arrays as the parameters to this function and you get back a dictionary. The first array elements are converted into … Continue reading

Posted in Blog Post | Tagged , | 1 Comment

Creating Conditional Lists in Python

This post is meant to be short and self explanatory. We can easily create lists in python based on given conditions. Have a look: list = [x for x in range(1,100)] It would create a list containing 1 to 99. … Continue reading

Posted in Blog Post | Tagged | Leave a comment

Python port to the Alphabet Class

I have a pretty bad habit of porting codes from one language to another. PHP and Python both are my favorites. But sometimes I feel that I enjoy coding more in Python than PHP. It’s just because I am a … Continue reading

Posted in Blog Post | Tagged | Leave a comment

Using web.py with Google App Engine

I love coding in Python and have been exploring the excellent web.py framework lately. From what I’ve seen, web.py is a very simple yet powerful python based web framework. It’d take me a lot of time to learn django (if … Continue reading

Posted in Blog Post | Tagged , , , | Leave a comment

Basic HTTP Server in Python

I just wrote a simple http server with Python. Here I share the code with you all View Source: http://dpaste.de/ASbi/ import BaseHTTPServer server_class=BaseHTTPServer.HTTPServer class masnun(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header("Content-Type","text/html") self.end_headers() self.wfile.write("You requested: <b>" + self.path + "</b> on localhost <br … Continue reading

Posted in Blog Post | Tagged | Leave a comment

Using Sub-applications on web.py

I have started learning the web.py framework for python. It’s simply a great framework. Here’s a code snippet I wrote a few minutes ago to try the sub-application feature of web.py. There is mainly two applications here à “app” and … Continue reading

Posted in Blog Post | Tagged , | Leave a comment

ZIP, Python and TK

The title says it all. Here’s a very simple program written in Python and TK which can extract a ZIP file to the selected location. Python 3 – Source Codes: —————————————- import zipfile import tkinter, tkinter.filedialog root = tkinter.Tk() root.title(“ZIP … Continue reading

Posted in Blog Post | Tagged | 1 Comment

Building GUI with Python and Tk

I have been looking for a decent GUI toolkit to develop some desktop programs. I worked with Java. Didn’t like the idea of typing that much to develop a app. Used php with WinBinder and PHP-GTK. Liked the first one, … Continue reading

Posted in Blog Post | Tagged | Leave a comment

Simple Console Clock for Windows with Python

The code is self explanatory: Python 3 Source Code: ———————————————- from threading import Timer # import the Timer class import os # import os library import time # import time library def main(): # define the main function os.system(“cls”) # … Continue reading

Posted in Blog Post | Tagged | Leave a comment

Python tool to expand short URLs

In one of my last posts, I posted a code snippet which demonstrated how to use php to expand short URLs to their original long form. Here’s the Python version I coded a few minutes ago. Python 3: import http.client … Continue reading

Posted in Blog Post | Tagged , | Leave a comment