Ask Your Question

test value of symbolic expression's operator

asked 2018-10-05 12:24:25 -0500

Wolan gravatar image

updated 2018-10-05 12:49:32 -0500

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 12:51:38 -0500

tmonteil gravatar image

updated 2018-10-05 13:11:28 -0500

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 12:24:25 -0500

Seen: 63 times

Last updated: Oct 05 '18