How to modify meaning of builtin function "not" to "!"?

Reedick, Andrew jr9445 at ATT.COM
Fri May 9 10:02:59 EDT 2008


> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of grbgooglefan
> Sent: Friday, May 09, 2008 9:41 AM
> To: python-list at python.org
> Subject: How to modify meaning of builtin function "not" to "!"?
> 
> I am creating functions, the return result of which I am using to make
> decisions in combined expressions.
> In some expressions, I would like to inverse the return result of
> function.
> 
> E.g. function contains(source,search) will return true if "search"
> string is found in source string.
> I want to make reverse of this by putting it as:
> if ( ! contains(s1,s2) ):
>      return 1
> 
> I found that "!" is not accepted by Python & compile fails with
> "invalid syntax".
> Corresponding to this Boolean Operator we've "not" in Python.
> 
> How can I make "not" as "!"?


Serious question:  Why would you want to?  'not' is easier to read (and type) than '!'.  Mentally, when you  see '!' you think 'not'.  It's also harder to overlook 'not', especially when compared to '!contains()'.  Finally, I imagine that Spanish speaking coders suffer enormous mental anguish when they see a right-side up '!' at the beginning of a sentence.

if ( ! contains(s1,s2) ):
     return 1

if ( !contains(s1,s2) ):
     return 1

if ( not contains(s1,s2) ):
     return 1

if ( ¡contains(s1,s2)):
     return 1




*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625





More information about the Python-list mailing list