Tag Archives: Python

Pydev: The Best Python IDE

While I don’t usually advertise, I love eclipse for all of its feature rich implementations of language specific IDE’s. Among those is Pydev, a complete first class IDE for Python.
Recently, Pydev just hit version 1.6.0 (Congratulations!) with the…

Posted in Programming, Python | Tagged , , , , , | Leave a comment

Python: Self references in List comprehension

One of the great abilities in Python that is copied over from Haskell is the ability to construct lists from other lists or iterators inline. This is of course limiting in certain cases where self references are necessary. For example,…

Posted in Blog, Programming, Python, Snippets | Tagged , , , , , , | Leave a comment

Python Tip: Copying an object

One of the several “features” of python that often land beginners head over feet with their faces in the mud is the distinction between references and copies. Say we have the following list a:

a = [1,3,5,7,9,11]

Posted in Blog, Programming, Python, Snippets | Tagged , , , , , , , , , , | Leave a comment

Brain Teaser: Multiply by 6

How do I go about multiplying a real number n by 6 in python without using the * or the + operators?

Solution:

x6 = lambda n: (n<<3) - n - n

Rationale:

n

Posted in Blog, Programming, Python, Snippets | Tagged , , , | Leave a comment

Linked Lists via ctypes in Python

from ctypes import *

class linknode(Structure):
    pass
linknode._fields_ = [
                ("nextNode", POINTER(linknode)),
                ("intData", c_int),
                ]
class linked_list():
    head_node = None
    def add(self, int_data):
        node_to_add = linknode(intData = c_int(int_data))
        if (self.head_node == None):
            self.head_node = node_to_add
        else:
            traverse_node

Posted in Programming, Python, Snippets | Tagged , , , , | Leave a comment

Best Hello World App Ever :D

Written in Python :D

See http://failboat.me/2009/cute-functions-creating-pseudo-operators-in-python/ for more details.

#Hello World

class Operator(object):
    def __init__(self, func, count=2):
        self._func_ = func
        self._args_ = []
        self._count_ = count
    def __ror__(self, first_arg):
        self._args_.append(first_arg)

Posted in Blog, Programming, Python, Snippets | Tagged , , | Leave a comment

Cute Functions – Creating pseudo-operators in Python

I ran across something today that I found to be extremely interesting. Basically, the authors of Should_DSL, http://pypi.python.org/pypi/should_dsl/1.2.1, have attempted and succeeded in creating pseudo-operators based on operator-functions within an object.

Let me elaborate.

The goal of Should-DSL

Posted in Blog, Programming, Python, Snippets | Tagged , , , , , , | 1 Comment

[Lua] MapParser (High Level API)

This is a Map parser library for CS2D’s lua engine. Benchmarked to process 6,000 tiles per second. (A 2,000% improvement over the older parser). This also demonstrates that it is possible to have object-orientation within a lua script

Posted in Blog, Lua, Programming, Snippets | Tagged , , , , , , , , , , , , , | Leave a comment