odd question

Heike C. Zimmerer usenet04q1 at hczim.de
Fri Jul 16 08:20:04 CEST 2004

Harald Massa <cpl.19.ghum at spamgourmet.com> writes:

> Bruno,
>>>>def f2(i, j, k):
>>>>  return ((i | j) & k) | (i & j)
>>>>Find a useful utilization for this function.
>>> This function is a possible proof that it is possible to write
>>> pearllike (=writeonly) code in Python too.
>> I thought anyone using a programming language had at least some
>> notions of boolean algrebra...
> putting down the truth-table is of course an exercise. 
> But for any means: to factor out theses boolean operators into a function 
> named "f2" AND "forgetting the doc string" will not help in a "more than 
> toy" programm.
> Yes, I could take this code and "run it on paper"
> Yes, I could cut and paste it into the interactive interpreter
> But: it is still write only. What does the code "expect"? Most people 
> here expected i,j,k to be boolean.

I surely didn't and I think most people didn't either since the
bitwise operators were used instead of the boolean ones.  So I'd
expect at least some of the operands to possibly be ordinals.

The most readable way of expressing ((i | j) & k) | (i & j) ist to
write it down exactly like this.  To a programmer, it shouldn't make
much difference if he'd used "+" and "*" instead of "|" and "&".



More information about the Python-list mailing list