Sublime Forum

Setting python math

#1

Hi friends,
I’m using the Sublime calculate plugin to do some in-line calculations for responsive design work. It’s great, except i’m having to manually include decimals if I want to get an integer answer. Here’s an example:

1 / 9 = 0
1.0 / 9  = 0.111111111111

Not the end of the world, but it takes me out of my zen-workflow, and generally harshes serious mellow.

this stackoverflow post has a way to set python to automatically do this, but as I’m not a dev, or all that familiar with configuring ST2, I don’t really know what to do.

Thanks!
Nick

0 Likes

#2

I don’t have the calculate plugin, but assuming it has a file named calculate.py you could open this in ST and add the following at the top of the file:

from __future__ import division

Exit ST before you test this, and delete the line if it doesn’t work.

If not, someone who has this plug-in might advise you :wink:

0 Likes

#3

I added the snippet to the top of my calculate.py and it works like a charm!
Thanks very much agibsonsw!

Nick

0 Likes

#4

[quote=“iota”]I added the snippet to the top of my calculate.py and it works like a charm!
Thanks very much agibsonsw!

Nick[/quote]

You’re welcome. Glad to see my psychic powers are still in full flow :wink:

0 Likes