Tutors,
I recently learned a bit about using the clnum package (see <
http://calcrpnpy.sourceforge.net/clnumManual.html>),and am trying to write a set of functions that I could import to do very precise division, raising any number to any power, etc., where the numbers can be strings in the form of "long floats", e.g., "1234.9872364091270983712639048710297".
I've succeed with a script, clnumDivision.py, (see it at < http://www.rcblue.com/Python/clnumDivision_for-web.py>) but it is not one function, but a script with 3 functions plus a main(). So my first question is how can I use this as a function that I could, for example, import into the interactive shell by a "from xxx import yyy", or an "import zzz"? Is the answer to put all 3 functions inside one big one?
Also, I'd appreciate knowing if there are easier ways to do some of the things I've done inside sciNotation() and numberRounding(), especially the former.
I've been experimenting, and came up with this solution. At least it works. I slightly rewrote < http://www.rcblue.com/Python/clnumDivision_for-web.py> as clnumDiv.py
(< http://www.rcblue.com/Python/clnumDiv.py>) and put it in
E:\Python25\Lib\site-packages\mine and can now import by
from mine.clnumDiv import clnumDiv
or by from mine.clnumDiv import clnumDiv as div
I can use this in other scripts, or at the interactive prompt:
from mine.clnumDiv import clnumDiv as div
>>> x = '1234.5678567856785678567856786586'
>>> y = '-.00098769876897687654654'
>>> prec = 50
>>> div(x, y, prec)
'-1.2499437030427053037075454076437920433253956536740E+006'
>>>
As I said, this works, but is clnumDiv.py organized correctly pythonically?
Also, I'm still hoping for some suggestions about the details of the code.
Thanks,
Dick Moores
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor