For review: PEP 308 - If-then-else expression
Andrew Dalke
adalke at mindspring.com
Sat Feb 8 20:35:50 EST 2003
Uncle Tim:
> > x = None if s.find("spam") else "eggs?"
> >
> > and the behaviour is exactly opposite. I wonder how many
> > times people will make that mistake?
>
> Fewer than make the other mistake here <wink -- but I make it too>: .find
> returns an index, not a bool, so the original leaves x at None if s begins
You assume I wasn't just writing an alternative to !s.startswith("spam")?
:)
Yeah, I saw that problem, and I'm really, really happy that
"spam" in s
is supported in 2.3
Who says I don't like change?
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list