Pixar's color scripts

Visualizing The Incredibles' color script.

The Duck Tale

The one about hand-making Korean wedding ducks.

Smile

Transforming sketches into a mixed media piece.

The mixed media process

A photo narrative about making a mixed media piece.


Method missing in Python

Posted on 2008-08-16 07:44:30

Here is a hacked up attempt of accomplishing Ruby's method missing in Python. While this is not as robust, it does manage to meet my needs.

class Thing(object):
    def __init__(self):
        self.__missing_method_name = None # Hack!
    
    def __getattribute__(self, name):
        return object.__getattribute__(self, name)
    
    def __getattr__(self, name):
        self.__missing_method_name = name # Could also be a property
        return getattr(self, '__methodmissing__')

    def __methodmissing__(self, *args, **kwargs):
        print "Missing method %s called (args = %s) and (kwargs = %s)" % (self.__missing_method_name, str(args), str(kwargs))

t = Thing()
t.badness(123, 'an arg', blah="another argument here", zesty="woot")

I would love to learn how to fully mimic Ruby's implementation and would appreciate any pointers.

Categories

Art
ColdFusion
Data Visualizations
Design
Inspiration
JavaScript
Life
Python
Ruby
Snippets

Elsewhere

Facebook
Gravity
Twitter

Subscribe to this blog


Content by Kunal Anand. Connect with me on Twitter, Facebook, or email.