What is the Best Way to use Python in the Windows Command Line

I teach a number of classes at the University of Michigan that are about Python and that use Python. We have gone from no Python classes last year to five classes and four teachers that teach Python at UM. We share intro documentation on how to install and set up the environment. One thing that really bugs me is that the WIndows Python installer does not add itself to the Path automatically. Since I insist that students can be allowed to use Mac's or PCs - I try to create a similar environment for both and the command line is the lowest common denominator. I end up publishing detailed documents and screen casts to get python into your Windows path. It works but it is not where I want students energy focused in the first week of class. I am wondering if there is another way. I generally do not like IDLE - it uses a socket which can get messed up, bugs in the student's code seem to mess up the IDE, when a program needs to open a data file - it is hard to force IDLE into a known directory. Is there a way to use an icon and then start the icon an have the current working directory (i.e. to open data files) be the same directory as the Python file? And then is there a way to get the output to stop at the end and not disappear when the program finishes? I do not like solutions which include adding code to the student programs to do things like pause before terminating or setting the current working directory. The students have enough trouble figuring out the 20 lines of code that matter let alone 5-6 lines of obtuse code to set up the environment. I can continue to teach them how to set the PATH variable in Windows - if anyone on this list has a suggestion - I would much appreciate it. Thanks. Charles Severance University of Michigan

Hi, maybe for the first weeks use crunchy, install a server somewhere, so they can use it, when you go further on the semester you can get them involved in the cli. Is a shame that advanced tools on the cli are hidden for people from GUI ones. Their minds will be "expanded" when they start to use the cli. Another way is to allow a machine with ssh for your students, so they are able to use say ajaxterm or something like that to start coding, they will be involved in having an account on a remote machine that holds they work. It turns interesting for people that are only used to "just" a PC(or MAC), without knowing the power of remote connections and the concept to **share** resources(machines and materials) and publish(public_html) their work. Well, if it's possible to setup a revision control system, on more courses, they will start to appreciate powerful tools, maybe the most advanced would be able to get in touch with many interesting things. My high school students started to use subversion and they got really involved and motivated when they saw graphics that showed their commits :) http://www.gfc.edu.co/repositorio/2008/ They have just finished their work now, but you can see a show of the work done of one of them on http://www.gfc.edu.co/~danmar/ He used visual python, pygame, curses and had a lot of fun coding... Finally, an option would be to have a linux(livecd) where the cli is really friendly where they have all the necessary packages without the hazzle of administering viruses and unpredictable results... P.D:We use Debian Linux at our school, and administration is really painless. Some of the students know how to install it, and have it also at their homes. This is a ongoing work that will reach its 10th aniversary ;) They start to use linux from 6 years old... csev> I teach a number of classes at the University of Michigan that are csev> about Python and that use Python. We have gone from no Python csev> classes last year to five classes and four teachers that teach Python csev> at UM. We share intro documentation on how to install and set up the csev> environment. csev> csev> One thing that really bugs me is that the WIndows Python installer csev> does not add itself to the Path automatically. csev> csev> Since I insist that students can be allowed to use Mac's or PCs - I csev> try to create a similar environment for both and the command line is csev> the lowest common denominator. csev> csev> I end up publishing detailed documents and screen casts to get python csev> into your Windows path. It works but it is not where I want students csev> energy focused in the first week of class. csev> csev> I am wondering if there is another way. csev> csev> I generally do not like IDLE - it uses a socket which can get messed csev> up, bugs in the student's code seem to mess up the IDE, when a program csev> needs to open a data file - it is hard to force IDLE into a known csev> directory. csev> csev> Is there a way to use an icon and then start the icon an have the csev> current working directory (i.e. to open data files) be the same csev> directory as the Python file? And then is there a way to get the csev> output to stop at the end and not disappear when the program finishes? csev> csev> I do not like solutions which include adding code to the student csev> programs to do things like pause before terminating or setting the csev> current working directory. The students have enough trouble figuring csev> out the 20 lines of code that matter let alone 5-6 lines of obtuse csev> code to set up the environment. csev> csev> I can continue to teach them how to set the PATH variable in Windows - csev> if anyone on this list has a suggestion - I would much appreciate it. csev> csev> Thanks. csev> csev> Charles Severance csev> University of Michigan csev> _______________________________________________ csev> Edu-sig mailing list csev> Edu-sig@python.org csev> http://mail.python.org/mailman/listinfo/edu-sig -- Recomiendo Inkscape para hacer gráficos vectoriales http://www.inkscape.org

I do not know if this is helpful but the web2py windows distribution includes portable python and does not require installation. You just type web2py.exe -S admin and you have a python shell or you can do web2py.exe -S admin -R /path/to/yourfile.py It includes Tk all standard python libraries. There are have some bonus features that students may find convenient like browser based editor with syntax highlighting, wysiwyg editor for HTML files and easy to use database API. Massimo On Dec 13, 2008, at 9:48 AM, Igor Támara wrote:
Hi, maybe for the first weeks use crunchy, install a server somewhere, so they can use it, when you go further on the semester you can get them involved in the cli.
Is a shame that advanced tools on the cli are hidden for people from GUI ones. Their minds will be "expanded" when they start to use the cli.
Another way is to allow a machine with ssh for your students, so they are able to use say ajaxterm or something like that to start coding, they will be involved in having an account on a remote machine that holds they work. It turns interesting for people that are only used to "just" a PC(or MAC), without knowing the power of remote connections and the concept to **share** resources(machines and materials) and publish(public_html) their work. Well, if it's possible to setup a revision control system, on more courses, they will start to appreciate powerful tools, maybe the most advanced would be able to get in touch with many interesting things.
My high school students started to use subversion and they got really involved and motivated when they saw graphics that showed their commits :) http://www.gfc.edu.co/repositorio/2008/
They have just finished their work now, but you can see a show of the work done of one of them on http://www.gfc.edu.co/~danmar/
He used visual python, pygame, curses and had a lot of fun coding...
Finally, an option would be to have a linux(livecd) where the cli is really friendly where they have all the necessary packages without the hazzle of administering viruses and unpredictable results...
P.D:We use Debian Linux at our school, and administration is really painless. Some of the students know how to install it, and have it also at their homes. This is a ongoing work that will reach its 10th aniversary ;) They start to use linux from 6 years old...
csev> I teach a number of classes at the University of Michigan that are csev> about Python and that use Python. We have gone from no Python csev> classes last year to five classes and four teachers that teach Python csev> at UM. We share intro documentation on how to install and set up the csev> environment. csev> csev> One thing that really bugs me is that the WIndows Python installer csev> does not add itself to the Path automatically. csev> csev> Since I insist that students can be allowed to use Mac's or PCs - I csev> try to create a similar environment for both and the command line is csev> the lowest common denominator. csev> csev> I end up publishing detailed documents and screen casts to get python csev> into your Windows path. It works but it is not where I want students csev> energy focused in the first week of class. csev> csev> I am wondering if there is another way. csev> csev> I generally do not like IDLE - it uses a socket which can get messed csev> up, bugs in the student's code seem to mess up the IDE, when a program csev> needs to open a data file - it is hard to force IDLE into a known csev> directory. csev> csev> Is there a way to use an icon and then start the icon an have the csev> current working directory (i.e. to open data files) be the same csev> directory as the Python file? And then is there a way to get the csev> output to stop at the end and not disappear when the program finishes? csev> csev> I do not like solutions which include adding code to the student csev> programs to do things like pause before terminating or setting the csev> current working directory. The students have enough trouble figuring csev> out the 20 lines of code that matter let alone 5-6 lines of obtuse csev> code to set up the environment. csev> csev> I can continue to teach them how to set the PATH variable in Windows - csev> if anyone on this list has a suggestion - I would much appreciate it. csev> csev> Thanks. csev> csev> Charles Severance csev> University of Michigan csev> _______________________________________________ csev> Edu-sig mailing list csev> Edu-sig@python.org csev> http://mail.python.org/mailman/listinfo/edu-sig
-- Recomiendo Inkscape para hacer gráficos vectoriales http://www.inkscape.org<signature.asc><ATT00001.txt>

Massimo Di Pierro wrote:
I do not know if this is helpful but the web2py windows distribution includes portable python and does not require installation. You just type
web2py.exe -S admin
and you have a python shell or you can do
web2py.exe -S admin -R /path/to/yourfile.py
It includes Tk all standard python libraries. There are have some bonus features that students may find convenient like browser based editor with syntax highlighting, wysiwyg editor for HTML files and easy to use database API. What do you use as the "browser based editor with syntax highlighting" and the "wysiwyg editor for HTML files " ?
thanks, Stef
Massimo

micedit and editarea Massimo On Dec 13, 2008, at 5:59 PM, Stef Mientki wrote:
Massimo Di Pierro wrote:
I do not know if this is helpful but the web2py windows distribution includes portable python and does not require installation. You just type
web2py.exe -S admin
and you have a python shell or you can do
web2py.exe -S admin -R /path/to/yourfile.py
It includes Tk all standard python libraries. There are have some bonus features that students may find convenient like browser based editor with syntax highlighting, wysiwyg editor for HTML files and easy to use database API. What do you use as the "browser based editor with syntax highlighting" and the "wysiwyg editor for HTML files " ?
thanks, Stef
Massimo
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig

csev wrote:
...We share intro documentation on how to install and set up ... I end up publishing detailed documents and screen casts to get python into your Windows path. It works but it is not where I want students energy focused in the first week of class. I am wondering if there is another way.
Have you considered contacting ActiveState? Their installers generally work very nicely for me, and I like to recommend them to people who want a turn-key install. I suspect you could talk them into some special deal to redistribute the installer as an academic institution, but at the very least your students could download their installer themselves for the economical price of $0.00. --Scott David Daniels Scott.Daniels@Acm.Org

On Dec 13, 2008, at 9:59 , csev wrote:
Is there a way to use an icon and then start the icon an have the current working directory (i.e. to open data files) be the same directory as the Python file? And then is there a way to get the output to stop at the end and not disappear when the program finishes?
What I do is the following: 1) I install the enthought version of Python, which puts an icon called Pylab on the desktop. This is short for ipython -pylab 2) I have the students make a work folder, and copy the Pylab shortcut to the folder 3) I have them change the "Start In" property of the icon 4) (if you don't want all the numerical stuff, then delete the -pylab option while you're in properties) then you can use whatever text editor you want (I use SciTE, because it comes with EPD, but you have to change the default tab settings). The shortcut, when run, will pull up the ipython commandline. then the students just type: run myprog.py whenever they want to run things. It seems to work ok, and you don't have to muck with the path. bb -- Brian Blais bblais@bryant.edu http://web.bryant.edu/~bblais

Several options, Charles. If they typically work from a particular directory, you can have them copy into that directory a batch file like py.cmd: path = %path%;c:\python26;c:\python26\Scripts;c:\python26\tools\scripts;C:\Python26\Lib\idlelib start "Python Enabled Command Window" Double clicking on it starts a console window that has Python in the path, and any further console window you open from within it with the start command inherit the same path. You can omit the idlelib part if you like. If you want the Python directories in the path generally, without diddling with the control panel, and if your students are already downloading a few files of yours, you might include pathman.exe from Microsoft's freely downloadable "Windows Resource Kit" plus another batch file for them to double click on: add26.cmd: pathman /au C:\Python26;c:\python26\tools\scripts;c:\python26\scripts This changes the global path when you open a console window in the future. If you have both 2.6 and 3.0 installed and want to go back and forth between having them as defaults, you can have a batch file like the following and a similar one to do the reverse. default26.cmd: ftype Python.CompiledFile="C:\Python26\python.exe" "%%1" %%* ftype Python.File="C:\Python26\python.exe" "%%1" %%* ftype Python.NoConFile="C:\Python26\pythonw.exe" "%%1" %%* pathman /rs C:\Python30;c:\python30\tools\scripts;c:\python30\scripts pathman /as C:\Python26;c:\python26\tools\scripts;c:\python26\scripts The first three lines make the right behavior when selecting a file in the GUI Windows directory browser. The /rs and /as in the pathman calls refer to the system path. If for some reason you are only manipulating the user path, use /ru and /au. Andy Harrington On Sat, Dec 13, 2008 at 8:59 AM, csev <csev@umich.edu> wrote:
I teach a number of classes at the University of Michigan that are about Python and that use Python. We have gone from no Python classes last year to five classes and four teachers that teach Python at UM. We share intro documentation on how to install and set up the environment.
One thing that really bugs me is that the WIndows Python installer does not add itself to the Path automatically.
Since I insist that students can be allowed to use Mac's or PCs - I try to create a similar environment for both and the command line is the lowest common denominator.
I end up publishing detailed documents and screen casts to get python into your Windows path. It works but it is not where I want students energy focused in the first week of class.
I am wondering if there is another way.
I generally do not like IDLE - it uses a socket which can get messed up, bugs in the student's code seem to mess up the IDE, when a program needs to open a data file - it is hard to force IDLE into a known directory.
Is there a way to use an icon and then start the icon an have the current working directory (i.e. to open data files) be the same directory as the Python file? And then is there a way to get the output to stop at the end and not disappear when the program finishes?
I do not like solutions which include adding code to the student programs to do things like pause before terminating or setting the current working directory. The students have enough trouble figuring out the 20 lines of code that matter let alone 5-6 lines of obtuse code to set up the environment.
I can continue to teach them how to set the PATH variable in Windows - if anyone on this list has a suggestion - I would much appreciate it.
Thanks.
Charles Severance University of Michigan _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
-- Andrew N. Harrington Director of Academic Programs Computer Science Department Loyola University Chicago 512B Lewis Towers (office) Snail mail to Lewis Towers 416 820 North Michigan Avenue Chicago, Illinois 60611 http://www.cs.luc.edu/~anh Phone: 312-915-7982 Fax: 312-915-7998 gdp@cs.luc.edu for graduate administration upd@cs.luc.edu for undergrad administration aharrin@luc.edu as professor

At 09:59 AM 12/13/2008 -0500, csev wrote:
I generally do not like IDLE - it uses a socket which can get messed up, bugs in the student's code seem to mess up the IDE, when a program needs to open a data file - it is hard to force IDLE into a known directory.
In Windows, drag the IDLE icon from the Start menu to your working directory. That creates a shortcut. Right click on the shortcut, and delete the "Start In" directory. Repeat for every directory you wish to make a working directory. Now when you click on one of those shortcuts, it starts IDLE with the current working directory prepended to the default sys.path. As for the "socket" problem, I think you are referring to the "dueling event loops" problem. If your program has an event loop involving Tkinter, your can't run it from IDLE, which also uses Tkinter. What works nicely for me, is to do all my editing in the nice environment provided by IDLE, but run the program from a separate command window. I also drag a command window shortcut to every directory where I need this strategy. There is a good explanation of setup in John Zelle's Appendix B. I know there are better IDE's available, but I keep coming back to IDLE. It does what I need without a lot of clutter. -- Dave

On Thu, Dec 18, 2008 at 6:18 PM, David MacQuigg <macquigg@ece.arizona.edu> wrote:
At 09:59 AM 12/13/2008 -0500, csev wrote:
I generally do not like IDLE - it uses a socket which can get messed up, bugs in the student's code seem to mess up the IDE, when a program needs to open a data file - it is hard to force IDLE into a known directory.
Path issues are endemic to computer world, but since filesystems are trees and trees are mathy data structures... Seems schoolish math should have more talk of trees, including DOM. I know path issues in Java have resulted in some hair tearing in corporate cube farms, lots of premature baldness probably. << GOOD ADVICE >>
I know there are better IDE's available, but I keep coming back to IDLE. It does what I need without a lot of clutter.
-- Dave
Yeah, ditto. So convenient, a great battery included. At the very least I want my editing canvas able to show not-Latin-1 characters, but that's almost any GUI editor these days, including a lowly Ubuntu terminal window running a Python shell. Here I'm providing some SQL-related math-oriented scaffolding for computer algebra students (probably redundant to call it that, might shorten to just algebra i.e. puzzle-solving algorithmic stuff aka gnu math...). http://www.4dsolutions.net/ocn/python/django_math.txt (also introduces regexps) Related screen shots: http://www.flickr.com/photos/17157315@N00/3118999641/ ( note url: mvp = most valuable player ) http://www.flickr.com/photos/17157315@N00/3119826690/sizes/o/ ( note url: .../mathy/trig/sin?angle=30 ) We might spend up to three weeks on something like this in the envisioned charters, e.g. tecc-alaska.org . Kirby
participants (9)
-
Andrew Harrington
-
Brian Blais
-
csev
-
David MacQuigg
-
Igor Támara
-
kirby urner
-
Massimo Di Pierro
-
Scott David Daniels
-
Stef Mientki