[Edu-sig] importing modules at IDLE startup
kirby.urner at gmail.com
Mon Nov 16 18:47:53 CET 2009
I created fred.py in site-packages of a 2.x for running in IDLE:
from __future__ import division
from math import sqrt
return (1/3, sqrt(2))
Students would have to use Recently Opened, fred.py, F5, which is not
what you want.
I encourage teachers to abandon 2.x at the earliest opportunity,
realizing we're looking at VPython so really can't afford the luxury
of cutting ties. Math without any VPython at all is hardly worth
On Mon, Nov 16, 2009 at 8:01 AM, Frederic Baldit <frederic38300 at aol.com> wrote:
> I'm using python (version 2.5.2, under debian lenny for personnal use on
> my notebook, and version 2.6 under Windows XP with my students) for
> teaching an introduction to algorithmic at High School (in France). I'm
> also using IDLE as IDE.
> Here is my problem (I try to solve it under linux fisrt):
> 1) I wrote a .pythonrc.py file with the two lines
> from __future__ import division
> from math import *
> 2) in my .bashrc file I wrote
> PYTHONSTARTUP = "/home/fred/.pythonrc.py"
> export PYTHONSTARTUP
> 3) when invoking python interactively in a terminal, it works fine:
> 4) I wrote a small script file test.py which contains
> print sqrt(2)
> print 1/3
> Editing/testing this file with IDLE with the following command line:
> idle-python2.5 -n -s test.py
> and executing it with F5 gives the lines
> IDLE 1.2.2 ==== No Subprocess ====
> So I have here a first problem with 1/3 division that should give a
> float result (according to the startup file import from __future__).
> 5) More annoying yet, when launching IDLE through the menu (under
> gnome), even the sqrt(2) command is not accepted (NameError: name 'sqrt'
> is not defined). I have checked that IDLE is launched with the
> command /usr/bin/idle-python2.5 -n -s
> Does anyone know how to solve this ? (of course I know that I could
> write 1.0/3, or also I could migrate to python 3). I simply want to
> "simplify" the python syntax for my students, so that "/" operator is
> always for them the usual (float) division, and usual math functions are
> available, this WITHOUT having to write any import at the top of their
> Thank's in advance for any valuable help.
> Edu-sig mailing list
> Edu-sig at python.org
More information about the Edu-sig