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

Terry Reedy tjreedy at udel.edu
Fri May 9 16:17:25 EDT 2008


"grbgooglefan" <ganeshborse at gmail.com> wrote in message 
news:fcdd681d-7786-4a09-8ba6-a2865352dfa1 at k10g2000prm.googlegroups.com...
|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 "!"?

1. Download, edit, and compile Python source code.
Perhaps substituting '!' for 'not' in the grammar file will suffice.
I do not *think* that this would conflict with '!=' digraph.
2. Realize that code for your custom Python will not work anywhere else if 
it does contain '!' with that meaning.






More information about the Python-list mailing list