We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thanks for the cool library! It would be nice to have a function that can parse a PhysicalQuantity from a string.
For usage outside ipython, it would be nice if this was available under a short name, such as the already existing q().
q()
A quick mock-up which just splits at whitespace:
from PhysicalQuantities import PhysicalQuantity, _Quantity, q _Quantity.__call__ = lambda s, x: PhysicalQuantity(float(x.split()[0]), x.split()[1]) print(q("1 m") / q("1 s")) # gives 1.0 m/s
It would also be useful for parsing string data loaded from files or input by user.
The text was updated successfully, but these errors were encountered:
Thanks for your interest :-) You can use transform_line from PhysicalQuantities.transform to do this, see: I use this here for example: https://github.com/juhasch/yamleins/blob/master/yamleins/__init__.py
transform_line
PhysicalQuantities.transform
Sorry, something went wrong.
Yeah, though that requires eval() which is quite risky when loading untrusted files.
eval()
No branches or pull requests
Thanks for the cool library!
It would be nice to have a function that can parse a PhysicalQuantity from a string.
For usage outside ipython, it would be nice if this was available under a short name, such as the already existing
q()
.A quick mock-up which just splits at whitespace:
It would also be useful for parsing string data loaded from files or input by user.
The text was updated successfully, but these errors were encountered: