Python Briefing for Faculty
I'm putting together a 2-3 hour briefing + demonstration for faculty to try to get them interested in Python for our introductory programming course, which uses a baffling subset of C++ at the moment. I thought I'd do it in a PC lab with Win2000 and use Python 2.0 + IDLE. I teach Python under Linux, but I think the windoze environment will be more convincing for them, and engaging for beginning programming students. I plan to discuss programming environments, provide an overview of the language, and have them type in some small programs. Anyone done this recently? Have any thoughts to contribute? Thanks, Dick S. - rhseabrook@mail.aacc.cc.md.us Anne Arundel Community College (410)541-2424 *** Speed the net! http://enterprise.aacc.cc.md.us/~rhs
I'm putting together a 2-3 hour briefing + demonstration for faculty to try to get them interested in Python for our introductory programming course, which uses a baffling subset of C++ at the moment. I thought I'd do it in a PC lab with Win2000 and use Python 2.0 + IDLE.
Maybe you want to consider to have a look at SciTE: http://www.scintilla.org/SciTE.html SciTE is a Text Editor with many nice features like syntax highlighting for many languages and filetypes (including Python), executing the Python-script by pressing F5 which raises an output area, jump to tracebacks by pressing F4, which makes hunting down errors very convenient. The Python interpreter is started in a separate process (very important for VPython programs). It is available on Win32 and Unix/Linux. It supports .api files which give you calltips for Python functions and classes which is also a very nice feature: http://stud4.tuwien.ac.at/~e9326522/gen_python_api.zip SciTE has support for multiple buffers and is quite configurable in any way. I do all my Python development with SciTE and prefere it to IDLE. Kind Regards, Markus
I have a pyfraction.py and a polynomial.py, which contain Fraction and Poly classes respectively. My problem is each class needs to know about the other, meaning I'm now doing an isinstance(other,Fraction) in Poly, and an isinstance(other,Poly) in Fraction. So how do I handle this. I have an import Fraction from pyfraction at the top of polynomial.py, and an import Poly from polynomial at the top of pyfraction.py This is obviously NOT the way to handle it, because it's a loop. In trying to import Fraction, it hits the line to import polynomial, which it's still trying to deal with. This problem arises now that I'm using isinstance(foo,bar) and need bar as a global. Earlier, I was doing type(foo).__class__.__name__ == "bar", which was ugly, but didn't require that I actually have any bars hangin' around. Kirby
Kirby Urner writes:
I have a pyfraction.py and a polynomial.py, which contain Fraction and Poly classes respectively.
My problem is each class needs to know about the other, meaning I'm now doing an isinstance(other,Fraction) in Poly, and an isinstance(other,Poly) in Fraction.
So how do I handle this. I have an
import Fraction from pyfraction
at the top of polynomial.py, and an
import Poly from polynomial
at the top of pyfraction.py
This is obviously NOT the way to handle it, because it's a loop. In trying to import Fraction, it hits the line to import polynomial, which it's still trying to deal with.
This problem arises now that I'm using isinstance(foo,bar) and need bar as a global. Earlier, I was doing type(foo).__class__.__name__ == "bar", which was ugly, but didn't require that I actually have any bars hangin' around.
I didn't have any trouble with a mutual import under Python 1.5.2: sample.py: #!/usr/bin/python import woo class Ample: def __init__(self): self.woo = woo.Woohoo() woo.py: #!/usr/bin/python import sample class Woohoo: def __init__(self): pass def gimmeanample(self): return sample.Ample() -- Seth David Schoen <schoen@loyalty.org> | And do not say, I will study when I Temp. http://www.loyalty.org/~schoen/ | have leisure; for perhaps you will down: http://www.loyalty.org/ (CAF) | not have leisure. -- Pirke Avot 2:5
Thanks Seth. Now that I'm following your example and importing the module, vs using import foo from bar, and writing type(woo,bar.foo) instead of type(woo,foo), it's working OK. I'm not sure that's the issue. It could be a path thing somehow, in the python21\ocn\mathobjects, which contains an __init__.py, isn't in my python path (\ocn is though). I go from mathobjects import *, and that brings Fraction, Poly, Matrix and Sqmatrix top level. Anyway, your example led me to working code.
from mathobjects import * f = Fraction(1,2) p = Poly([1,0],'t') p t f (1/2) p*f (1/2)*t f*p (1/2)*t
Gratefully, Kirby -----Original Message----- From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of Seth David Schoen Sent: Thursday, May 10, 2001 5:56 PM To: edu-sig@python.org Subject: Re: [Edu-sig] Technical question I didn't have any trouble with a mutual import under Python 1.5.2: <<SNIP>>
I'm putting together a 2-3 hour briefing + demonstration for faculty to
-----Original Message----- From: edu-sig-admin@python.org [mailto:edu-sig-admin@python.org]On Behalf Of Markus Gritsch Sent: Thursday, May 10, 2001 1:45 PM To: Seabrook, Richard; edu-sig@python.org Subject: Re: [Edu-sig] Python Briefing for Faculty try
to get them interested in Python for our introductory programming course, which uses a baffling subset of C++ at the moment. I thought I'd do it in a PC lab with Win2000 and use Python 2.0 + IDLE.
Maybe you want to consider to have a look at SciTE: http://www.scintilla.org/SciTE.html <<SNIP>> SciTE has support for multiple buffers and is quite configurable in any way. I do all my Python development with SciTE and prefere it to IDLE. Kind Regards, Markus ============ scintilla looks interesting. I have a question about it though. In IDLE, I can assign variables and they persist, as do references to whatever imported stuff. As I do this and that interactively, I make use of these references -- I'm sitting in a pile of tools and they all stay defined from one command to the next (plus I create new ones at will). It's like using a calculator with any number of STORE keys, plus you can store anything you like (objects of any kind -- which may be functions). With scintilla, it looks like I boot an instance of Python every time I invoke a command (e.g. print 'hi'), plus I have to disk-save that command as a .py file in advance before I can use it. I'm not really in an interactive mode at all, but am executing a whole py module top to bottom and then exiting Python. If so, this seriously detracts from some of the benefits associated with IDLE, and even with interactive Python in a DOS box. You don't really have an environment. Nothing persists except disk files. You can't define A = Matrix(...) and then refer to it 10 minutes later, after doing a bunch of other stuff, maybe passing it as an argument to something imported from another module. There's no real conversation. Do I have the wrong idea here? If I'm correct, then scintilla may well be a very useful text editor, and good for doing *some* things in Python, but it's not creating a trully interactive Python session (using "session" as we might in APL, Logo or DrScheme -- interactive access to persistent data without saving to files). Maybe people coming from C++ or Java or Fortran don't really miss being in a session, having a true command line, because these are compile-link-run type languages. But those of us used to sitting in a command window and working interactively really notice when that power is suddenly gone (which doesn't mean we don't code in edit mode -- just that being in edit mode is not entirely synonymous with "using the language", is only half the story). Kirby
If so, this seriously detracts from some of the benefits associated with IDLE, and even with interactive Python in a DOS box. You don't really have an environment. Nothing persists except disk files. You can't define A = Matrix(...) and then refer to it 10 minutes later, after doing a bunch of other stuff, maybe passing it as an argument to something imported from another module. There's no real conversation.
Everything you mentioned is totally correct. SciTE is an general Editor, but has no interactive window built in. I you enjoy interactive sessions, IDLE is definitely the tool to use. As you mentioned, It depends on your habbits. I don't use Python as an advanced calculator, and defining more complicated stuff (loops, conditions) on the commandline is awkward. Anyway, even when experimenting with features I write the code in SciTE and execute it. Since startup-time of the interpreter is neglible this is no problem, although there is no persistency (as you also mentioned). As already mentioned, it depends on your habbits. Regards, Markus
Yes, we agree. And I've downloaded and am using Scintilla now too, and I think I'm going to like it. Most of my curriculum writing around Python depends on the student importing modules and then interacting with them. "Advanced calculator" might be the term, but it's what Scheme, APL, Logo, Xbase and many other languages feature -- a shell. Basically, it's a way to get the user freedoms of event driven programming without having to write a fancy GUI (take advantage of the one you already have).
getfactors(100) [2,2,5,5]
... stuff like that.
From a beginner/learner/first language point of view, I think having a shell is a tremendous asset. If you can't go:
1 + 1 2
or (+ 1 1) in Scheme, then I don't think it's very suitable, at least not for the math-through-programming curriculum type stuff I'm developing. Kirby =================== <<SNIP>> As already mentioned, it depends on your habbits. Regards, Markus _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
I must have not missed something.. Isn't PythonWin using scintilla? I prefer PythonWin to IDLE most of the time. +++++ object.lookup command line completion pop up menu [YES!!] +++ easy to add new mdules to the PYTHONPATH [which I still do not really understand on win32] ++ nice color and formatting control ++ expand/contract code sections using 'Folding' option [free man's Mathematica-style notebook] + visible indentation guides [see View Menu] + configurable 'Tools' Menu + zoomable display CTRL + mousewheel + some Python modules that won't run under IDLE do under PythonWin - some Python modules that won't run under PythonWin do run under IDLE ./Jason _____________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
Isn't PythonWin using scintilla?
Yes it does, but scintilla is only the editor-component. Script-startup isn't performed by the editor-component, but by the embedding application. So SciTE is the text-editor which uses scintilla as it's editor-component. (In fact SciTE was only developed as a demonstration application for scintilla, but has improved so much, that it is a powerful editor now.) Try the following in the interactive window of PythonWin: while 1: pass and PyrthonWin will never ever respond to something again.
I prefer PythonWin to IDLE most of the time.
+++++ object.lookup command line completion pop up menu [YES!!]
can be done to some extend also with SciTE
+++ easy to add new mdules to the PYTHONPATH [which I still do not really understand on win32]
Ever looked at HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.0\PythonPath in the registry?
++ nice color and formatting control
More controllable in SciTE
++ expand/contract code sections using 'Folding' option [free man's Mathematica-style notebook]
Code-folding is a feature of scintilla itself
+ visible indentation guides [see View Menu]
ditto
+ configurable 'Tools' Menu
comparable feature available in SciTE
+ zoomable display CTRL + mousewheel
CTRL Num+ in SciTE
+ some Python modules that won't run under IDLE do under PythonWin - some Python modules that won't run under PythonWin do run under IDLE
There is no module that couldn't be run in SciTE. Every script is interruptable by a menu entry. Markus
Hi Markus Many thanks for the heads up on SciTE. Very interstin & yes I am impressed - it does feels smooth, clean and fast. I like the Save As HTML/RTF/PDF How do you run python scripts? How do you do the object.lookup tricks? How do you navigate between multiple open files. There is no 'Window' menu to jump between open documents. I am probably just being lazy and nee to read the dosc adn study configs for a while. There has been a growing demand for a smart I toolkit for Zope. looks liek SciTE could be a very nice part of that, using wxPython/Boa. It's proabbly already in there.. Have you any experience embeding and scripting SciTE in python apps? cheers ./Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
Hi Markus
Many thanks for the heads up on SciTE.
Very interstin & yes I am impressed - it does feels smooth, clean and fast. I like the Save As HTML/RTF/PDF
How do you run python scripts?
by pressing F5 (look into the SciTE docs)
How do you do the object.lookup tricks?
Well, since it is only an Editor (although a very good one), and not a Python IDE, object.lookup is not possible. I wrote "to some extend possible", and that means, that calltips and autocompletion is possible. For example when configured properly, typing string. will pop up a window with all the functions an classes in the stirng module. Typing more e.g. string.split( will show the calltip of the function. This information must be stored in an .api file (as discribed in the SciTE docs), and I have written a little script which generates such an .api file form the standart Python library: stud4.tuwien.ac.at/~e9326522/gen_python_api.zip
How do you navigate between multiple open files. There is no 'Window' menu to jump between open documents.
You must turn on multiple buffers. Have a look into my attached SciTEUser.properties file.
I am probably just being lazy and nee to read the dosc adn study configs for a while.
In deed. But you can save some time by using parts of the attached file. It changes also the colors to be more IDLE like.
There has been a growing demand for a smart I toolkit for Zope. looks liek SciTE could be a very nice part of that, using wxPython/Boa. It's proabbly already in there..
Have you any experience embeding and scripting SciTE in python apps?
No. And once again: SciTE is the Text Editor. SciTE, T=text E=editor. scintilla is the editor-component, and you definitely want to embed scintilla into your application. Please make this distinction. Enjoy, Markus
On Thu, 10 May 2001 22:45:09 +0200, "Markus Gritsch" <gritsch@iue.tuwien.ac.at> wrote about Re: [Edu-sig] Python Briefing for Faculty: :The Python interpreter :is started in a separate process (very important for VPython programs). Is this not the case with PythonWin? I might introduce the VPython module to my students, but right now they only have IDLE and PythonWin on their computers. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/
Is this not the case with PythonWin? I might introduce the VPython module to my students, but right now they only have IDLE and PythonWin on their computers.
No, IIRC PythonWin and definitely IDLE start the scripts in their own Process space, which was one of the main reasons why VPython includes a modified version of IDLE which also uses a separate process for the programs to be executed. This is especially important when using while 1: do_some_stuff as is regularly found in VPython programs. Regards, Markus
participants (6)
-
Jason Cunliffe
-
Kirby Urner
-
Markus Gritsch
-
Seabrook, Richard
-
Seth David Schoen
-
Sheila King