[IronPython] Contains() doesn't work anymore for sys.modules?
jimhug at exchange.microsoft.com
Tue May 24 00:49:10 CEST 2005
The underlying implementation of module dictionaries changed from IDictionary to IDictionary<object,object>. If you're trying to use the CLS methods, you'd want ContainsKey. However, this might easily change again as it should be an internal decision. In fact, it's probably a bug in IronPython that these methods are exposed on module dictionaries at all.
You should be doing this in the Pythonic way:
'site' in sys.modules
Or if you really want to call a method
When possible you should stick with standard Python-style code as it will both be most compatible with other versions of IronPython but also between IronPython and CPython. To what degree IronPython should force you to do this is still an open question, and not one I want to get into today...
Thanks - Jim
From: users-ironpython.com-bounces at lists.ironpython.com [mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of Sumit Basu
Sent: Monday, May 23, 2005 3:37 PM
To: users-ironpython.com at lists.ironpython.com
Subject: [IronPython] Contains() doesn't work anymore for sys.modules?
IronPython.Objects.Dict dictionaries seem to be changed in a strange way in 0.7.5...
IronPython.Objects.PythonValueError: bad args to this method <method# Contains on IronPython.Objects.Dict>
at IronPython.Objects.ReflectedMethodBase.Call(Object args)
at IronPython.Objects.Ops.Call(Object func, Object arg0)
at input_36.Run(Frame frame)
at IronPython.Hosting.PythonEngine.DoOneInteractive(Frame topFrame)
Looking at the doc string, it seems to want some sort of key-value pair - but Contains should just take a key, no?
More information about the Ironpython-users