For loops in Jython 2.1

View: New views
1 Messages — Rating Filter:   Alert me  

For loops in Jython 2.1

by Anthony Smith-11 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm trying to adapt a Java class so that "for" loops run smoothly in  
Jython 2.1, but I'm getting confused.

At the moment I'm overriding __getitem__(int), which the API says I  
shouldn't do, and it's giving a java.lang.IndexOutOfBoundsException  
after looping over the items.

Could someone point me to a simple explanation of what happens when a  
"for" loop is called?
        for a in b:
                ...
Which methods are invoked and in which order?  __getitem__(PyObject)?  
__finditem__(...)?

(I think __iter__ is a Python 2.2 innovation, so I guess that's not  
involved in Jython 2.1?)

Thanks!

Anthony



------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users