Re: [Deskbar] Calculator Handler for Deskbar



On Wed, 2005-11-16 at 02:24 +1100, Andrew Kerr wrote:
> I have written a handler for deskbar to do maths.
> 

Wonderful, i think we may ship something like that in deskbar, it's
always useful to do a quick computation without having to open
calculator. Besides math expressions are easy to detect and so the math
handler would only popup when needed.

> Idea: Type maths expressions into deskbar, python evaluates it (with
> decimal floating point arithmetic!) and allows you to copy the result to
> the clipboard. Can paste result back into deskbar if you want to keep
> calculating!
> 

That is a good approach, but there is on something i don't like.. That
monstruous regular expression :)

> Right now it supports addition (+), subtraction (-), multiplication (*),
> division (/), exponentials (**) and scientific notation (eg: 5e-3). Any
> expression that does not evaluate is silently ignored (uncomment the two
> trackback lines to debug).
> 

Isn't there any other way to evaluate an expression ?
Maybe just calling 'eval expr' would be good enough ? if we pass in the
context of eval the various constants and well known functions ?

> Future:
> * configuration option to set precision (just saw that this is planned)
This is overkill, using just 2 or 3 decimals is good enough, who wants
more can either use a real calculator, or maybe a hidden gconf key.


So, before this gets included, i would like that regex to disappear
using a saner way to compute expressions :)

Thanks !
Raf






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]