Here's a little snippet that'll entertain the vast throngs of people who are interested in both Rock Paper Scissors strategy and Django unit testing.
for futile_attempt in range(100):
For the uninitiated:
Through the magic of statistical analysis, I have created a mostly-correct am-i-jogging-in-the-near-future detector.
Will I Jog?
A colleague of mine was wistfully pining for Haskell-style currying in Python. This sounded like an interesting syntactic feature, so I decided to see if I could toss together something that would at least emulate the behavior of returning functions when a function is called with too few arguments. I've always admired the flexibility of python, so it seemed like an interesting challenge to prove that.
Using a decorator seemed like a bit of a copout due to the additional syntax required, but was otherwise ideal, as it made checking arguments fairly trivial.
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
except TypeError, t:
return lambda *_args,**_kwargs:f(*(args+_args), **(dict(kwargs.items()+_kwargs.items())))
Continue reading "Implementing Partials in Python"
I put the code for a silly iPhone app that I wrote many weekends ago up on github in the hopes that it might be useful to someone. It handles touches in a kind of strange way and handles audio playback in a kind of normal way, so it might be handy as an example.
It's available for tinkering over on github.