Python’s Does Not Not Have a Not

I’m new to Python; trying to write a little script.  I need to use the “not” operator.  At first, I tried the nearly universal ! operator.  Syntax error – that’s not it.  So I open my handy Python in a Nutshell book, and look up the operators (pg 36).  Sure enough, ! is not one of them.  Hmm.  So, I look in the index for “not”.  “not” is not there.  Could it be that Python has not got a not?

No, of course it does not not have a not.  I found the answer on pg 50 – the not operator is aptly named “not” – e.g. “if not foo:”

Not funny?  Not was not in the index!

One thought on “Python’s Does Not Not Have a Not

  • November 9, 2007 at 12:40 pm
    Permalink

    Learning python eh?

    My current company is all python. When I first started learning python I was really sad. I thought that java was the tits.. However, after two years of python I have a hard time even thinking about writing other languages..

    The language is just so freakin nice, intuitive, and clean. Try contrasting the language to Ruby and you’ll see what I mean.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *