[IronPython] Overriding __iter__ in dict subclass

Dino Viehland dinov at exchange.microsoft.com
Wed Feb 20 00:38:12 CET 2008


This one's interesting.  I've got a fix for this for 2.0 on my machine - I've been looking at some other tweaks to dictionaries so we can cleanup our type system (funny how those two are related) and this fits in nicely with that.  So it should be in the next release.  Thanks for the report!

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Tuesday, February 19, 2008 8:31 AM
To: Discussion of IronPython
Subject: [IronPython] Overriding __iter__ in dict subclass

Bug in IronPython 1 and 2.

IronPython 2.0 Alpha (2.0.0.800) on .NET 2.0.50727.832
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> class X(dict):
...  __iter__ = lambda s: s.itervalues()
...
 >>> a = X([(1, 'a'), (2, 'b'), (3, 'c')])
 >>> for e in a:
...  print e
...
1
2
3
 >>>



IronPython 1.1
 >>> class X(dict):
...   __iter__ = lambda s: s.itervalues()
...
 >>> a = X([(1, 'a'), (2, 'b'), (3, 'c')])
 >>> for e in a:
...  print e
...
1
2
3
 >>>

CPython 2.4

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> class X(dict):
...  __iter__ = lambda s: s.itervalues()
...
 >>> a = X([(1, 'a'), (2, 'b'), (3, 'c')])
 >>>
 >>> for e in a:
...  print e
...
a
b
c
 >>>

--
Michael Foord
Senior Software Engineer, Resolver Systems Ltd.
michael.foord at resolversystems.com
+44 (0) 20 7253 6372

We're hiring! http://www.resolversystems.com/jobs/
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK

_______________________________________________
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