The function has_key is useful to find out if a particular key exists in a dictionary, before trying to use it.
>>> primitive['square'] Traceback (most recent call last): File "", line 1, in ? KeyError: square >>> if primitive.has_key('square'): ... print primitive['square'] ... else: ... print 'no such key' ... no such key