[C++-sig] dict surprise
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Sat Jul 20 05:54:50 CEST 2002
I was surprised to find that
dict(w_obj.attr("__dict__")).update(some_tuple[0]);
only updates the temporary created by dict(), but not the original __dict__.
Eventually I got the desired behavior by using
w_obj.attr("__dict__").attr("update")(object(some_tuple[0]));
I convinced myself that the first statement works just the way Python works, so
fine. However, this is a bit of a trap for the novice and a specific warning in
the documentation ("don't use dict(obj1).update(obj2)") would probably be very
helpful.
Ralf
P.S.: I love the new extract<T> .
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
More information about the Cplusplus-sig
mailing list