On Monday 16 November 2009 2:27 pm Frederic Baldit wrote: > Le lundi 16 novembre 2009 à 13:15 -0800, Mark Voorhies a écrit : > > > 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. > OK, now I have the "new" division active, both when starting idle > through the command line and with gnome menu! Unfortunately, when > starting idle with gnome menu, I cannot use sqrt(2) (but it works when > runing idle in a command line with -s option). I hardly believe that > PYTHONSTARTUP is not set up, because according to env PYTHONSTARTUP is > set to /home/fred/.pythonrc.py.
A good way to test the environment that python/idle is seeing is: import os os.environ["PYTHONSTARTUP"] > I tried to create an .xsession file in > my home (after reading the link you gave), but had to remove it because > X could not start. > > I really don't understand this difference between running idle-python2.5 > through command line (which works) and through gnome menu. When you start a bash terminal session (e.g., via gnome-terminal) ~/.bashrc is sourced and the resulting environment is passed to any programs started from that terminal session. I believe that the environment seen by programs launched from the gnome menu is set up through some combination of your login manager (e.g., gdm) and Xsession, in a fairly distro dependent way. In my hands, this means that I can see my ~/.bashrc environment from python or idle launched from a bash shell, but not from the gnome menu. > Fixing this > would definitively solve my problem... I still try to fix this point. If you don't want to muck around with Xsession config files, and you're hacking the idle-python2.5 script anyway, you can modify the environment from within the script: ---------------------------------------------------- #! /usr/bin/python2.5 -Qnew import os os.environ["PYTHONSTARTUP"] = "/home/fred/.pythonrc.py" from idlelib.PyShell import main if __name__ == '__main__': main() ----------------------------------------------------- --Mark > > Thank you very much for your help. I fully understand that it is best to > teach students setting up the environment at the beginning of their > script, but here my goal is really not to teach programming, only the > first steps in a introductory (and very basic) course on algorithmic. > > Frédéric. > -- To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org