OdeToCode IC Logo

Looking Back: Python

Thursday, July 11, 2013

Rabbints, Campfires, PythonTrue story: My first use of Python was a little over 10 years ago.  I used Python to prevent rabbits from running into campfires and injuring themselves.

Of course the rabbits were virtual, as were the campfires. I was working with a team to create MMORPG middleware, and Python scripts were the brains for some of the lesser NPCs.

I’ve been working with Python again recently.

class Cart:

    def __init__(self):
        self.contents = dict()

    def process(self, order):        
        if order.add:            
            if not order.item in self.contents:
                self.contents[order.item] = 0
            self.contents[order.item] += 1

        if order.delete:
            if order.item in self.contents:
                self.contents[order.item] -= 1
                if self.contents[order.item] == 0:
                    del self.contents[order.item]

    def __repr__(self):
        return "Cart: {0!r}".format(self.__dict__)

It’s interesting how my opinion of Python has changed. Ten years ago the majority of my programming experience was with C, C++, and Java. My thoughts on Python were:

1. Using indentations to control block structure was weird, considering white space was insignificant everywhere else.

2. Tuples were useful.

3.  Double underscores look cool

Todays thoughts:

1. Tuples are still useful, but the REPL perhaps more so.

2. How did I miss lambdas, generators, map, filter, and reduce?

3. Double underscores are ugly, but the absence of { and } and is beautiful.

I like Python, it’s a great language. I have a better appreciation for its features today than I did 10 years ago.

Gravatar Tyrone Thursday, July 11, 2013
Yeah, I picked up Python about a year ago and was blown away by it's simplicity in some areas. String manipulation and list comprehensions are my favorite features.
Gravatar tobi Thursday, July 11, 2013
I think the primary criterion for any language and framework is: how productive is it? Syntax is mostly orthogonal to that question. The other features you mention are important, though.
Gravatar Anil Friday, July 12, 2013
I'm really interested in Python lately and very happy to see you blogging about it. Can we expect a Python line of courses on Pluralsight soon ;)
Gravatar Scott Saturday, July 13, 2013
@Anil - yes, there will be very soon.
Comments are closed.