Message49291
Logged In: YES
user_id=1424288
Here's an example of a little typed environment. It's not
the most robust, but it gets you thinking.
import code
class TypedDictionary(dict):
def __setitem__(self, key, value):
if self.has_key(key):
t = type(self[key])
if t != type(value):
try:
value = t(value)
except Exception:
raise TypeError, \
"illegal assignment to '%s':" \
" %s cannot be coerced to %s" \
% (key, type(value), t)
dict.__setitem__(self, key, value)
code.interact(local=TypedDictionary()) |
|
Date |
User |
Action |
Args |
2007-08-23 15:45:16 | admin | link | issue1402289 messages |
2007-08-23 15:45:16 | admin | create | |
|