Open michaellisitsa opened 3 years ago
Hi @michaellisitsa,
This is another limitation of handcalcs: I do not know of a way to handle this scenario, in general, without handcalcs doing some eval
work which I would like to avoid. handcalcs just gathers two pieces of data: the raw source in a cell and a dictionary of variables. It then, artfully I think, swaps variable names for variable values and then replaces a bunch of substrings contained within the raw cell source. Without a variable name to assign the answer to, e.g. a = 2+2
, there is not much I can do to get the resulting value.
Note, that when using IPython, the variable _
stores the output of the most recently run cell. This could potentially work for solving this problem but it would only work in IPython/Jupyter and it would not work with the decorator which is why I am reluctant to implement it. It would also require the other feature you suggested (#55) which I plan on implementing at some point because I think it's a good move.
So, perhaps this might be possible but it will be a lower priority for me.
I like the idea of having it in Jupyter, if you can easily extract the resultant value from the _
variable. I was thinking that for newcomers who are trying to get handcalcs to work, it will probably be the first thing they try, particularly if they've come from Mathcad etc. They are unlikely to start learning handcalcs via the decorator methods.
Completely understand the low priority, I don't have too many uses for having above functionality.
@michaellisitsa,
I have been thinking about this and I want to tackle this next. I think it would be really cool if handcalcs could do this, especially now that #55 has been implemented.
That's great to hear. If you figure how to decouple the rendering from a variable assignment, may it can open up the gates to comment lines #Line only has comment
to be rendered (providing commentary in between calculations, without having to split with Markdown cells in Jupyter)
When entering an arithmetic equation without a variable assignment, handcalcs creates an error.
How to reproduce
Expected Behaviour
Error Message