[IronPython] Iterating over Dictionary<int, str> returns the wrong objects?

Martin Maly Martin.Maly at microsoft.com
Mon Sep 26 18:44:00 CEST 2005

Hi Ray,

With .NET Frameworks Beta 2 the behavior is exactly as you observe,
however, I found that your code works as expected on the newest builds
of .NET Frameworks, including the Visual Studio Release Candidate build
available to MSDN subscribers.


-----Original Message-----
From: users-ironpython.com-bounces at lists.ironpython.com
[mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of
Ray Djajadinata
Sent: Sunday, September 25, 2005 6:28 AM
To: users-ironpython.com at lists.ironpython.com
Subject: [IronPython] Iterating over Dictionary<int, str> returns the
wrong objects?


I'm trying to print the contents of a Dictionary<int,
string>. In C# I can do this:

foreach (KeyValuePair<int, string> pair in myDict) {

However, in IP, typing this:

>>> myDict = Dictionary[int, str]()
>>> # ... do stuff here ...

>>> for pair in myDict:
...     print str(pair)

or this:

>>> for pair in myDict:
...     print pair.ToString()

gives me this:


Instead of KeyValuePair<int, string> instances, I was getting
DictionaryEntry-s instead, whose ToString() method indeed prints the
fully qualified name of the instance (instead of anything meaningful). 

Is there a workaround or I should just wait for the fix? :)

Thank you!

Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
users-ironpython.com mailing list
users-ironpython.com at lists.ironpython.com

More information about the Ironpython-users mailing list