1-2-3 testing... I created fred.py in site-packages of a 2.x for running in IDLE:
from __future__ import division from math import sqrt def test(): return (1/3, sqrt(2)) print test() if __name__=="__main__": test() 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 pursuing. Kirby On Mon, Nov 16, 2009 at 8:01 AM, Frederic Baldit <frederic38...@aol.com> wrote: > Hello, > 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: > >>>> 1/3 > 0.33333333333333331 >>>> sqrt(5) > 2.2360679774997898 > > 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 ==== >>>> >>>> > 1.41421356237 > 0 > > 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 > script. > > Thank's in advance for any valuable help. > Frederic. > > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig > _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig