Categories
Python

Python: Encoding and Decoding Strings as Bytes

It’s simple!

Python IDE Entries:

It’s quite interesting. Last night, when I was using urlopen to access the TinyURL API, I found that the data was being returned as bytes. I had to decode it.

Categories
Python

Python Program To Generate TinyURLs

In a previous post of mine, I have published a php class to generate short urls using the TinyURL API. Here is a simple Python program to generate tiny URLs directly from your desktop.

The File: (Python 3)

How To use?
Save the file as “tinyurl.py”.
You have to pass a target URL as the only argument to the program. The short url will be printed out on your screen.
Type the following command on your cmd or shell to execute the program.

tinyurl.py https://masnun.com

The short url will be printed out on the screen (shell or cmd).

If you don’t know or like the idea of copying text from the command line interface, simply redirect the output of the program to a text file:

tinyurl.py https://masnun.com > url.txt

The above code will fetch the short URL and put it into the file named “url.txt” 🙂 I use this method.

To Do: I am thinking of adding the functionality to create multiple short url from a single execution.

Categories
Python

Google App Engine Sample Apps

I recently found this URL: http://code.google.com/p/google-app-engine-samples/

It’s a Google Code project with links to some cool sample app source codes.

I haven’t yet checked them out. But I liked the online demo of the “Shell” app. It’s really nice: http://shell.appspot.com/

Take your time to have some real fun J with these projects.