Python's and and Pythons or

Chris Angelico rosuav at gmail.com
Thu Oct 10 04:03:01 EDT 2013


On Thu, Oct 10, 2013 at 6:43 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> y = x and 1/x
> One just has to remember that y==0 effectively means y==+-infinity ;-).

Good example. Extremely appropriate to situations where you're showing
a set of figures and their average:

Foo   1
Bar   3
Quux  7
Asdf  9
===== 5

Let the average show as zero if there are none, it won't hurt:

print("=====",count and total/count)

ChrisA



More information about the Python-list mailing list