[Eric] Eric4 vs Python3.1
detlev
detlev at die-offenbachs.de
Wed Mar 3 18:02:45 GMT 2010
On Mittwoch, 3. März 2010, Zhu Sha Zang wrote:
> 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)??
Eric determines this based on the file extension (or the project type, if it
is part of a project). These extensions may be configured on the Python page
of the config dialog.
If Python3 is the default Python I would recommend using eric5, which is the
Python3 port of eric4 (with enhancements like py3flakes checks).
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the Eric
mailing list