Boolean tests [was Re: Attack a sacred Python Cow]
ethan at stoneleaf.us
Wed Jul 30 10:49:55 CEST 2008
Carl Banks wrote:
> On Jul 29, 6:42 pm, Matthew Fitzgibbons <eles... at nienna.org> wrote:
>> I don't have any postable code (it's in a half way state and I haven't
>> touched it for a while), but I'll see if I can't find the time to bang
>> something up to give you the gist.
> I wouldn't bother at this point. I was looking to see if someone
> could come up with something to disprove my belief on the polymorphic
> uselessness of "if x" relative to explicit tests, and if (as I
> anticipated) they did not, I could claim that "if x" is really just a
> glorified keystroke saver. But I now realize that the failure of this
> bunch doesn't prove anything. I don't think most people even realize
> why answering the question I asked would demonstrate the usefulness of
> "if x".
> Your example isn't exactly the smoking gun I was looking for, but I
> guess we'll have to admit that at least one usage will suffer for not
> having it.
> Carl Banks
Even for those that did realize, and in fact hoped that that is what you
were attempting to accomplish, it was still quite frustrating to see you
ignoring all the non-code, yet perfectly valid examples of why "if x"
was not only valid, but the most pythonic way to get the task done.
I think it would have been a better discussion if you had responded with
reasons why, and not just parroted the "show me the code!" line over and
over and over and ... It seemed as if you thought you were the
professor, impatiently trying to teach a class full of idiots by playing
the devil's advocate. I was sure hoping someone would get the actual
code example and post it, partly because I enjoy learning, but mostly
because it would (hopefully) shut you up and move the conversation
along. In fact, somebody did post some code about a custom matrix
class, where __len__ was useless, and still you kept on with... pah.
It's late, so before I say something stupid I'll finish this. My last
thought on the matter -- up until this thread I had looked forward to
your posts, Carl. I think you did more damage than good to yourself
with this stunt.
 by pythonic I mean using the features of the language that make
sense. In this case, the __nonzero__ function to have the object in
question tell us whether or not it's empty. This seems so basic (the
__nonzero__ function, that is, and its purpose) -- do you really need
code to prove it to yourself?
More information about the Python-list