[Baypiggies] Baypiggies snippets
davidoff56 at alluvialsw.com
Thu Mar 22 07:30:27 CET 2007
Chad Netzer wrote:
> ... I was
> thinking about a "There's more than one way to do it in Python, too"
> type-thing, and I was going to solicit examples from the list. I
> figured it could generate some instructive examples for newbies night.
> ... I'd love to see other simple contributions of
> pythonic "There is more than one way to do it". :)
This is one of my favorites:
# Here are expressions that are idiomatic in many languages to check
# that a number is within an interval:
x >= a and x <= b
a <= x and x <= b
# But in Python, you can also say:
a <= x <= b
Another simple one worth knowing early on.
More information about the Baypiggies