[IronPython] Comparing clr objects in lists

Fuzzyman fuzzyman at voidspace.org.uk
Tue Oct 3 14:38:24 CEST 2006


Andrzej Krzywda wrote:

>Hello all,
>
>We found an issue with comparing clr objects in lists.
>
>IronPython 1.0.60816 on .NET 2.0.50727.42
>Copyright (c) Microsoft Corporation. All rights reserved.
> >>> import clr
> >>> clr.AddReference('System.Drawing')
> >>> from System.Drawing import Color
> >>>
> >>> Color.Red == Color.Red
>True
> >>> (Color.Red) == (Color.Red)
>True
> >>> [Color.Red] == [Color.Red]
>False
> >>> [(Color.Red)] == [(Color.Red)]
>False
>
>The same kind of comparison will work with IronPython objects.
>
>  
>
Unlucky. :-)

By the way, the following are exactly equivalent :
>>> Color.Red == Color.Red

True
 >>> (Color.Red) == (Color.Red)
True


If you want to try in tuples, use :

 >>> (Color.Red,) == (Color.Red,)


Michael
http://www.voidspace.org.uk

>Andrzej Krzywda
>_______________________________________________
>users mailing list
>users at lists.ironpython.com
>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>  
>




More information about the Ironpython-users mailing list