[Twisted-Python] copy domish element

Phil Mayers p.mayers at imperial.ac.uk
Mon Jun 8 13:03:53 EDT 2009

Jack Bates wrote:
> i have a domish element - when i try the following,
>>>> message = element
>>>> del message['from']
>>>> element['from']
> - i get a key error

Well, yes. That's how python works ;o)

> to avoid this key error, i think i want to copy the element, so i can
> drop the 'from' attribute from one copy without affecting the other?
> but i didn't find anything to make a copy in the domish element api

I haven't tried it, but have you tried the python standard copy protocol:

import copy
message = copy.deepcopy(element)

More information about the Twisted-Python mailing list