pint
pint copied to clipboard
user defined unit prints
I want to do something like this:
myval = ureg.Quantity(0.4,ureg.dimensionless,repr='[-]')
print("myval =",myval)
> myval = 4 [-]
myval2 = 5 * ureg.m / myval
print("myval2 =",myval2)
> myval2 = 5 m
is this possible somehow?
[-] would be the representation of dimensionless?
well yes. [] is usually for units, i.e. "power [MW]" and "-" is for "no unit". It's just for convenience since i use a lot of units like kWh, A,V, and then "dimensionless" takes a lot of space compared to the others. Only minus "-" would be also convenient. but basically i want to replace the default print name by a user text.