Ask Your Question

test value of symbolic expression's operator

asked 2018-10-05 19:24:25 +0200

Wolan gravatar image

updated 2018-10-05 19:49:32 +0200

tmonteil gravatar image

I need to define a boolean function is_pow that takes for argument a symbolic expression expr an that return True if and only if expr.operator is the builtin function pow. But I don'n know which the syntax to use:

Of course

def is_pow(expr):
 return expr.operator() ==  <built-in function pow>

doesn't work. Has someone the answer ? Thanks a lot.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-05 19:51:38 +0200

tmonteil gravatar image

updated 2018-10-05 20:11:28 +0200

You can compare wth operator.pow:

sage: expr.operator() == operator.pow

Or even:

sage: expr.operator() is operator.pow
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-10-05 19:24:25 +0200

Seen: 215 times

Last updated: Oct 05 '18