[Eric] Eric4 vs Python3.1

Zhu Sha Zang zhushazang at yahoo.com.br
Wed Mar 3 14:32:32 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey dudes, i'm trying to run this simple "program" in python (of
course inside eric4).
/
# coding: utf8

import cmath
import math
import sys
import unicodedata
import codecs


def get_float(msg, allow_zero):
    x = None
    while x is None:
        try:
            x = float(input(msg))
            if not allow_zero and abs(x) < sys.float_info.epsilon:
                print("zero is not allowed")
                x = None
        except ValueError as err:
            print (err)
    return x

print ("ax\N{SUPERSCRIPT TWO} + bx + c = 0")
a = get_float("enter a: ", False)
b = get_float("enter b: ", True)
c = get_float("enter c: ", True)

x1 = None
x2 = None

discriminant = (b**2) - (4*a*c)

if discriminant == 0:
    x1 = -(b / (2*a))
else:
    if discriminant > 0:
        root = math.sqrt(discriminant)
    else:
        root = cmath.sqrt(discriminant)
    x1 = (-b + root) / (2*a)
    x2 = (-b - root) / (2*a)

equation = ("{0}x\N{SUPERSCRIPT TWO} + {1}x + {2} = 0" " \N{RIGHTWARDS
ARROW} x = {3}").format(a, b, c, x1)
if x2 is not None:
    equation += " or x = {0}".format(x2)
print(equation)/

But, when i try run scrip receive this message.

The debugged program raised the exception unhandled KeyError
"SUPERSCRIPT TWO"
File: /media/pendrive/PYTHON/quadratic.py, Line: 46


Testing inside a shell with python prompt the error is the same.
Testing with python3 or python3.1 the program works well.

The question?

How i made Eric4 runs scripts using python3.1 instead python2 (2.6.4
in here)??

Att...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuOcwAACgkQ35zeJy7JhCga9ACfeNIDRgMM6iwy7l4ZRoZ8YBfO
THAAoIuUu/o+kSVLDVvZEVvg5O12/WrE
=+z2I
-----END PGP SIGNATURE-----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/eric/attachments/20100303/afb4dd4e/attachment.html>


More information about the Eric mailing list