Jun 16, 2009 22:25
I have been playing around with Python some more. Because I still don't have anything sensible to write, I've just been doing another thing I always do: yet another text adventure. They're easy enough to make, anyway.
So far the mistake I've made most often is forgetting return:
def stuff():
print "Do some things here."
return True
def morestuff():
print "Let's do some things!"
stuff()
if morestuff():
print "Did some things!"
This prints "Let's do some things!", then it prints "Do some things here.", but it does *not* print "Did some things!". I keep forgetting that. The fix is, of course, to use return stuff() instead of just stuff().
My brain is still primarily Haskell-wired. This also manifests itself in a tendency to avoid global variables, but instead passing the game's state to all the function calls. And that I find myself explicitly def-ing a lot of things and then using them only once... this *should* be the purpose of a lambda, if only statements were allowed in them.
But so far, so good. I should now look at some of the libraries.