|
From: Robert W. B. <rb...@di...> - 2001-04-12 21:47:14
|
Hello Jim,
On Thu, 12 Apr 2001 Jam...@i2... wrote:
> I don't have easy access to the latest Jython release so I don't know if
> this is still a problem (maybe someone could check :-) ) but in the
> version I'm using vars() and foo.__dict__ (for a module foo) return an
> object which is not a dict and therefore cannot be used in the update
> method for dicts. This is kind of a pain when you have a local dict and
> need to update the values from a module import. The workaround is to loop
> through all the values individually (yuk).
I'm not sure what implications there is in doing this - I've only had a
second to look at it. However, here's a patch to PyDictionary.java that
allows PyStringMap, as in:
>>> d = {}
>>> d.update(vars())
<disclaimer>
This should be tested/studied before a case is made for this type of
change. This is only meant as 'just in case it is helpful' or 'maybe a
start'.
</disclaimer>
====================diff PyDictionary.java=============================
--- PyDictionary.java Thu Apr 12 21:11:22 2001
+++ jython/org/python/core/PyDictionary.java Sun Mar 4 12:08:59 2001
@@ -54,10 +54,6 @@
dict.update((PyDictionary)arg);
return Py.None;
}
- else if (arg instanceof PyStringMap) {
- dict.update((PyStringMap)arg);
- return Py.None;
- }
else
throw Py.TypeError("dictionary expected, got " +
arg.safeRepr());
===================================================================
Cheers,
Robert
|