"Kay Schluehr" <[EMAIL PROTECTED]> writes:
> Hmm. A statement has side-effects but it returns no value. And yes, you
> can create a name within an expression producing a value in Python,
> using a list/generator comprehension. The solution to Bob's problem
> would look like this:
> 
> if (I for I in (a.find("3"),) ) != -1:
>      print "It's here: ", I
> else:
>      print "No 3's here"

I think that works for list comprehensions but not generator
comprehensions.  With generator comprehensions, the index variable's
scope is limited to the comprehension.  With list comprehensions
there's a wart in that the index variable is still around afterwards.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to