Ask Your Question
1

test value of symbolic expression's operator

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

Wolan gravatar image

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

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
2

answered 2018-10-05 12:51:38 -0600

tmonteil gravatar image

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

You can compare wth operator.pow:

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

Or even:

sage: expr.operator() is operator.pow
True
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

Stats

Asked: 2018-10-05 12:24:25 -0600

Seen: 33 times

Last updated: Oct 05