Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
1

test value of symbolic expression's operator

asked 6 years ago

Wolan gravatar image

updated 6 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 6 years ago

tmonteil gravatar image

updated 6 years ago

You can compare wth operator.pow:

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

Or even:

sage: expr.operator() is operator.pow
True
Preview: (hide)
link

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: 6 years ago

Seen: 264 times

Last updated: Oct 05 '18