Re: importer des modules au démarrage d'IDLE
On Monday 16 November 2009 9:15 am Kumar Appaiah wrote:
> > idle-python2.5 -n -s test.py
> >
> > et que j'exécute avec F5 je n'ai pas d'erreur mais la division n'est pas
> > flottante:
> >
> > IDLE 1.2.2 ==== No Subprocess ====
> > >>>
> > >>>
> > 1.41421356237
> > 0
>
> I would guess the same thing would happen even in this case. The
> reason why this is NOT possible in Python is because if you effect
> such changes, the moment the script is run on another machine, it'll
> break. So, other than a hackish solution which someone could suggest,
> I can't think of a way to achieve this effect (elegantly).
One such hackish solution is to use a modified version
of /usr/bin/idle-python2.5 that invokes the python interpreter with "new"
division, e.g.:
------------------------------------
#!/usr/bin/python2.5 -Qnew
from idlelib.PyShell import main
if __name__ == '__main__':
main()
-------------------------------------
idlelib.PyShell.main will parse command line arguments, so invoking with -s
will still see your PYTHONSTARTUP script.
To have PYTHONSTARTUP set correctly in Gnome on Lenny, I think you need to
edit ~/.xsession rather than ~/.bashrc, c.f.:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=242507
(I don't have a desktop copy of Lenny, so I can't verify directly).
I do agree with Kumar that it might be best to teach students to do set up the
environment themselves at the top of their scripts.
--Mark
Reply to: