Modifying the {} and [] tokens
Dan Bishop
danb_83 at yahoo.com
Sat Aug 23 11:56:07 EDT 2003
Geoff Howland <ghowland at lupineNO.SPAMgames.com> wrote in message news:<mtqdkv8sdrmgrn02vugnbpuhtjsgel3ohb at 4ax.com>...
> I want to modify the {} and [] tokens to contain additional
> functionality they do not currently contain, such as being able to add
> dicts to dicts, and other things that would be very helpful for me and
> my team mates to have.
The only way to do that is to modify the C code for the interpreter.
Otherwise, you'll have to stick with
>>> class NewDict(dict):
... def __add__(self, other):
... result = self.copy()
... result.update(other)
... return result
...
>>> NewDict({1:2}) + NewDict({3:4})
{1: 2, 3: 4}
More information about the Python-list
mailing list