show(pi) will show a nice representation of pi, while pi.n() will yield a useable value
how am I supposed to achieve the same functionality for a custom 'symbol' ?
like
Az = 5.5 # cm the surface area of my Cylinder
but showing 'Az' as representation, not the value
I solved this with a custom Class, but this feels wrong:
class Myconst(Constant):
def __init__(self, name='Az', value=1.0):
Constant.__init__(self, name,
latex=None, domain='positive')
self.v = value
def __float__(self):
return self.v
def _real_double_(self, R):
return self.v
def _mpfr_(self,R):
return self.v
Az = Myconst(name='Az', value = 2.0).expression()
#As = Myconst(name='As', value = 5.0).expression()
now these work like I want them to :) Az.n() show(1/Az)
But is this the intended approach?