Categories
Python

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:

It would create a list containing 1 to 99. I get impressed by the power of Python the more I dig deeper into this fantastic language.

Categories
PHP

Converting Array to Object in PHP

Here’s a funny little code snippet that demonstrates the flexibility of PHP. Here, we first define an array. Then cast it into an object. And guess what, the keys of the arrays become public variables of the newly created object.

I was impressed to find it out…. Just have a look :

Cool, eh ? 😉

Categories
Python

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 lazy guy who hates using text editors to complete a script entirely before executing the program. I like interactive shells. Now that I have set up interactive shell for PHP as well, I write little throw away programs in both PHP and Python. But it still happens that the Python interactive interpreter is loads better than the PHP one. I have to type “echo” every time I want some input from the PHP shell, where as I have to type the name of an element (variable, object, list, tuple or whatever) and python displays it on the shell. So it becomes easier to experiment and debug.

Back to the topic, I was thinking of porting the alphabet class I wrote in PHP to Python. And finally I got some time today morning and finished it.

How to use ?

Source Code