On Feb 27, 2018 09:50, Alan Gauld via Tutor <tutor@python.org> wrote:
> On 27/02/18 05:13, Cameron Simpson wrote:
> > hard to debug when you do. That's not to say you shouldn't use them, but 
> > many
> > people use them for far too much.
> > Finally, you could also consider not using a regexp for this particular 
> > task.
> > Python's "int" class can be called with a string, and will raise an 
> > exception
> And, as another alternative, you can use all() with a
> generator expression:
> >>> all(c.isdigit() for c in '1234')
> True
> >>> all(c.isdigit() for c in '12c4')
> False

I never understood why this is syntactically correct. It's like two parentheses 
are missing.

This I understand:
all((c.isdigit() for c in '12c4'))
Or this:
all([c.isdigit() for c in '12c4'])
Or this:
all((True, False))

But the way you wrote it, the generator expression just "floats" in between the 
parentheses that are part of the all() function. Is this something special 
about all() and any()?
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to