In the following code:
chars = set('AEIOU')
...
if any((cc in chars) for cc in name[ii]):
print 'Found'
What is the “(cc in chars)” part? I know that it is applied to each cc that is generated by the for loop. But is the “(cc in chars)” construct itself a generator expression?
Thanks.
No, the
(cc in chars)part is a boolean expression;inis a sequence operator that tests ifccis a member of the sequencechars. The parenthesis are actually redundant there and could be omitted.