> What do you find most readable: your version, with an ad-hoc function
> defined somewhere else, far away in the code, or a simpler:
> for (x,y,z=0) in tupleList:
>     do_whatever_with_it()

I came up with the "ad-hoc function"
to give a kind of replacement
for the used syntax, in order
not to ask why not immediately:
for tuple in tupleList:
  do_whatever_with_it()
?

Sure I like the syntax as long as
I think in terms of unpacking
tuples, but at the first glance
I thought that the intention
was to get only x, y from the tuple
setting all z in the yielded tuples
to zero (as suggested in this
thread by giving the example of
going from 3D down to 2D where
with all z=0 the algorithm will
remain the same).
What about
"for (x,y,if z not in tupleList: z=0 else: z=1) in tupleList"
?

What if the tupleList is empty?
Should existing z be set to zero
or not after the line with the
for loop was executed?

Should
for (,y) in tupleList:
 do_whatever_with_it()
give only the y and
for (,,z) in tupleList:
only the z values?

If it should become possible to
use the "for (x,y,z=0) in tupleList"
syntax, I would sure like also to have:
"for (,,z) in tupleList"

"for (x,y,if z not in tupleList: z=0 else: z=1) in tupleList"
"for (x,y,if z not in tupleList: z=0 else: z=2*x*z) in tupleList"
and sure also:
"for (x,y,z=0, *r) in tupleList"
etc.

My only objections are:

Is it worth the effort?
Would it not be confusing?

Maybe starting with e.g. a
  xlistcomprehension
module where
xlistcomprehension.execute(
"[for (x,y,if z not in tupleList: z=0 else: z=1) in tupleList]"
)
or just xl(...) to keep it short
provides the desired functionality
is a good idea?
Then it can be seen if this module
becomes widely used and therefore
worth to be integrated?

I think it would be nice to have, but I
can't imagine it to be really very helpful.

It is sure a long way before the concept
of it becomes so mature, that all who
see it say:
Wow, why was it not from the very
beginning there?

Claudio


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to