[Python-Dev] Lockstep iteration - eureka! (original) (raw)
Thomas Wouters thomas@xs4all.net
Wed, 9 Aug 2000 18:15:39 +0200
- Previous message: [Python-Dev] Lockstep iteration - eureka!
- Next message: [Python-Dev] Lockstep iteration - eureka!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Aug 09, 2000 at 04:01:18PM +0100, Just van Rossum wrote:
PEP: 1716099-3 Title: Index-enhanced sequence iteration Version: Revision:1.1Revision: 1.1 Revision:1.1 Owner: Someone-with-commit-rights
I'd be willing to adopt this PEP, if the other two PEPs on my name don't need extensive rewrites anymore.
Features
It adds an optional clause to the 'for' statement: for indexing in :
Ever since I saw the implementation of FOR_LOOP I've wanted this, but I never could think up a backwards compatible and readable syntax for it ;P
Disadvantages:
It will break that one person's code that uses "indexing" as a variable name.
This needn't be true, if it's done in the same way as Tim proposed the 'form from import as as as' syntax change ;)
for_stmt: 'for' exprlist [NAME exprlist] 'in' testlist ':' suite ['else' ':' suite]
If the 5th subnode of the expression is 'in', the 3rd should be 'indexing' and the 4th would be the variable to assign the index number to. If it's ':', the loop is index-less.
(this is just a quick and dirty example; 'exprlist' is probably not the right subnode for the indexing variable, because it can't be a tuple or anything like that.)
-- Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
- Previous message: [Python-Dev] Lockstep iteration - eureka!
- Next message: [Python-Dev] Lockstep iteration - eureka!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]