grbgooglefan a écrit :
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.

Do you really need a function for this ?

if "foo" in "foobar":
   print "do you really really need a function for this ?"


I want to make reverse of this by putting it as:
if ( ! contains(s1,s2) ):
     return 1

which is a convoluted way to write:

  return s2 not in s1


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 "!"?

Err... How to say... The boolean negation operator in Python is "not". So the only answer I can provide is : "use 'not' instead of '!'". And while we're at it : drop those useless parens.

HTH
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to