On Feb 27, 2018 09:50, Alan Gauld via Tutor <firstname.lastname@example.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')
> >>> all(c.isdigit() for c in '12c4')
I never understood why this is syntactically correct. It's like two parentheses
This I understand:
all((c.isdigit() for c in '12c4'))
all([c.isdigit() for c in '12c4'])
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: