From csmith@blakeschool.org Fri Feb 1 23:07:21 2002 From: csmith@blakeschool.org (Christopher Smith) Date: Fri, 01 Feb 2002 17:07:21 -0600 Subject: [Edu-sig] Re: sitecustomize and pythonstartup In-Reply-To: References: Message-ID: dyoo@hkn.eecs.berkeley.edu writes: >On Fri, 1 Feb 2002, Christopher Smith wrote: > >> OK, the question is this. The interpreter can be educated as to what >> modules are loaded (i.e. if pythonstartup imports math, you can type >> math.pi in the interpreter and be understood). Is there a way to get >> this to happen in the IDE's interpreter as well? If sitecustomize.py >> imports math I can't seem to access that at the >>> prompt. > >Yes, it's possible. If we add the following fragment to our >sitecustomize.py: > >### >import math >import __builtin__ >__builtin__.math = math >del math >### > >then the math module will magically turn on for all new interactive >sessions. Pretty convenient! *grin* At least, this works from a regular >interpreter window; I'm not quite so sure if this will work with all >IDE's. > OK...I got my homework for the weekend: figure out how this is working. It works like a charm! On the mac's IDE both the interactive console and new scripts automatically can access math without an explicit import once the lines suggested above have been put into the sitecustomize.py script. Thanks, Danny. Have a nice wekend. /c From Jason Cunliffe" PythonStation => diskless linux stations Message-ID: <00d901c1abfb$acbd1b60$6501a8c0@jasonic> Greetings.. Yesterday at LinuxWorld Show in New York I saw Linux running on Sony Playstation2: http://www.cnn.com/2002/TECH/ptech/01/31/linux.ps2.idg/index.html http://playstation2-linux.com/ also lots of good information on linuxdevices.com: http://www.linuxdevices.com/news/NS3628477348.html which also points to nice Linux on DreamCast article: http://www.linuxdevices.com/articles/AT7466555948.html You probably won be surprised to hear SDL [Simple DirectMedia Layer] figures in this. Python has wrappers for SDL as used in PyGame http://pygame.org/ Stephen Figgins wrote an article last October about it: http://www.onlamp.com/pub/a/python/2001/10/04/pythonnews.html The action was all at the GPL .org booths. Some guys from the Japanese Linux Users Group had all sorts of cool thing going on, including Linux on Sega Dreamcast, and sundry other hand held computers and PDAs. The hack which caught my eye was a little tool called "ttrec". A small cli program which allows one to record and playback anything going on in tty terminal. An extension of the old Unix 'talk'. ttrec/ttplay is perfect for edu-sig because it does not behave like call and response port-based app. Instead it is natural VCR for console action. The flow is completely normal. Each character appears exactly as a entered by user or as computer echoes responses. Perfect for teaching python or any other cli activity in a shared environment or for later / remote use. The programmer told me it is a tiny c program he wrote. But by far the most edu-significant and exciting things I saw yesterday were developments for diskless workstations. There are a couple of closely related GPL efforts underpinning this: http://EtherBoot.org http://rom-o-matic.net http://ltsp.org Linux Terminal Server Project etherboot.org showed how one can take almost any ethernet card [$5 - $25] and install a ROM on it containing a tiny kernel. They This allows a PC to boot faultlessly from network server. The beauty is that one only has to maintain one central machine. Etherboot boots very quickly. Perfect for schools and classrooms. These guys are incredibly adept at writing tiny drivers and squeezing code onto EPROM's and flashdisks. It turns out that almost all BIOS with PCI will recognize these, and most ethernet cards have a vacant EPROM slot sitting there. The etherboot guys had a basketful of different cards on display and the list of supported hardware is impressive; Etherboot Network Interface Card Database http://etherboot.sourceforge.net/db/ LTSP is The complement to etherboot. Linux makes a great platform for deploying diskless workstations that boot from a network server. The LTSP is all about running thin client computers in a GNU/Linux environment. That means cheap silent PCs [no moving parts] which use standard keyboards mice and monitor. Boots in 22 seconds from a server. Then launches a XWindows GUI such as Gnome or KDE. viola! This is not gimmick, they had all kinds of heavy use running which we monitored remotely. The implications are many. Terminals are old idea in computers. What has changed is the price/performance of servers, Linux and all the desktop GUI applications now being developed. For schools.libraries etc this means the budget can go much further. Only one server to maintain. Cheap terminals everywhere else need no maintenance and can take the abuse typical of public computers. Jim McQuillan from LTSP said they have been working on it for 3 years. Now things are working well looking they are looking towards lots of exciting developments, including wireless and configuring with displays as one piece. He showed me a whitebox [diskless PC size of a small dictionary. Unit cost $400, but if he could order a container full [approx. 8000 units] from Taiwan the price drops to about $200 each. Add mouse, keyboard, monitor, extra RAM if desired.. The arithmetic per classroom/library is clearly very compelling. Lets say for every 20-40 terminals you need one good fast late model PC. The rest can be Cheap too expensive for you? I met a guy who lives in Delaware. Said his local recycling center [glass plastic etc] also has load of old PCs sitting there which nobody wants. These make perfectly good diskeless terminals. In his case he took them home and built a supercluster in his living room.. Go ahead let Bill Gates donate lots of hardware. Then strip em down and use etherboot and LTSP! A major issue for computing in schools/libraries is that people fail to understand/budget for maintenance and sysadmin. I was just reading about this problem in UK now. The above scenes depend on running ethernet to every station. Alternatives are to use wireless. There is a grassroots wireless movement in New York and elsewhere. NYCWireless.net has maps, links to other cities, how-tos etc. http://www.nycwireless.net/ http://www.nycwireless.net/links.html Looks like it is gonna be a very interesting year.. ./Jason ______________________________________________ Jason Cunliffe [NOMADICS: Director art+design] tel/fax: +1 718 422-1078 jasonic@nomadics.org N 43:00.000' W 074:31.875' ALT:1144 ft 84 Henry Street #3C Brooklyn NY 11201 USA From delza@mac.com Sat Feb 2 19:06:44 2002 From: delza@mac.com (Dethe Elza) Date: Sat, 2 Feb 2002 11:06:44 -0800 Subject: [Edu-sig] Contagious Fun => PythonStation => diskless linux stations In-Reply-To: <00d901c1abfb$acbd1b60$6501a8c0@jasonic> Message-ID: Wow, thanks for the update, Jason. Sounds like a great show. There's a great success story about switching to linux on diskless workstations from Windows, in the Largo, Florida city hall. Pretty much a win/win. http://www.newsforge.com/article.pl?sid=01/08/10/1441239&mode=thread I'm hoping to be able to pay some attention to Contagious Fun soon, especially PyGame, but my startup is picking up momentum and it's keeping me out of trouble (also away from things like food, sleep, family, etc.) --Dethe -- Dethe Elza (delza@burningtiger.com) Chief Mad Scientist Burning Tiger Technologies (http://www.burningtiger.com) Weblog: http://livingcode.manilasites.com/ From Jason Cunliffe" PythonStation => diskless linux stations References: Message-ID: <005e01c1ac43$a9677300$6501a8c0@jasonic> Hi Dethe > http://www.newsforge.com/article.pl?sid=01/08/10/1441239&mode=thread Thanks. Good article. for multicultural balance how about this: Raising the Red Flag? Is it possible that the top Linux distribution--at least for desktops--is Red...Flag? http://www.linuxjournal.com/article.php?sid=5784&mode=thread&order=0 Glad to hear your startup is going well. Good luck.. New Flash6 beta _player_ just came out friday. Immediate good news is it is over 10 times faster for XML processing and hadnels large data files better too.. That means attractive front ends for XMLapps. Meanwhile, I've been busy too, thus backlog of contagious fun contributions to still catch up on. ./Jason From Jason Cunliffe" ePython distance learning.. Message-ID: <006601c1ac48$1f2dc2c0$6501a8c0@jasonic> For anyone interested here's Satoru Takabayashi's wonderful ttyrecpage: http://www.namazu.org/~satoru/ttyrec/ ttyrec is a tty recorder. Recorded data can be played back with the included ttyplay command. ttyrec is just a derivative of script command for recording timing information with microsecond accuracy as well. It can record emacs -nw, vi, lynx, or any programs running on tty. tty mania presents ttyrec videos. Please set your terminal size to 80x24 and have fun! http://tty.namazu.org/ rpms http://www.ping.de/~michael/RPMS/ ..etc ttyrec is immediately usable for anyone on Linux system, and I think any *nix including MacOSX. Seems to have been based on some Ruby work. I think it would be great to have a native python version of ttyrec/ttyplay built-in to all distros: IDLE, PythonWin, VPython, PyGeo, PythonCard, PyGame.. With or without that, E-Python tutorials, distance learning, training and seminars could take on a new kind of dynamic life. This is brilliant tool for learning/teaching the sequence rhythms of using Python. Literally, show what is programming? Installation how-tos Gathers stats on the main stumbling blocks, and behavior of beginners. feedback See how students progress. Preload lessons, libraries desmos and debugging. PythonLiveDoc: [Essential Reference, Standard Library] Learn by watching the masters at work. Support tool for pro-cli computer literacy presentations PythonTV ContagiousFun It exhibits a simple genius: lowfi/hifi, like VNC http://www.uk.research.att.com/vnc/ ./Jason ______________________________________________ Jason Cunliffe [NOMADICS: Director art+design] tel/fax: +1 718 422-1078 jasonic@nomadics.org N 43:00.000' W 074:31.875' ALT:1144 ft 84 Henry Street #3C Brooklyn NY 11201 USA From groups@crash.org Sun Feb 3 18:41:42 2002 From: groups@crash.org (Jason L. Asbahr) Date: Sun, 3 Feb 2002 12:41:42 -0600 Subject: [Edu-sig] Contagious Fun => PythonStation => diskless linux stations In-Reply-To: <00d901c1abfb$acbd1b60$6501a8c0@jasonic> Message-ID: In addition, I've already ported Python 2.1 to the Playstation 2, and will continue to maintain it both on the professional dev unit and I'm looking forward to running Python on Sony's new consumer Linux kit. As soon as I can get my hands on it! http://www.asbahr.com/python.html Playstation 2 consoles will probably never replace PCs and Macs in schools, but being able to program games for one does lend a certain helpful "wow" factor. Good for student recruitment, I'm sure. :-) Jason Asbahr jason@asbahr.com From urnerk@qwest.net Wed Feb 6 17:36:39 2002 From: urnerk@qwest.net (Kirby Urner) Date: Wed, 06 Feb 2002 09:36:39 -0800 Subject: [Edu-sig] Using Flash animations to teach Python In-Reply-To: References: <00d901c1abfb$acbd1b60$6501a8c0@jasonic> Message-ID: <4.2.0.58.20020206093032.01a0a600@pop3.norton.antivirus> Lou Talman on one of the math discussion lists I frequent brought my attention to: http://www.mathematica.co.kr/mathcomm/20_definitionviz/index.html which uses short animations of symbolic expressions to communicate the meanings of Mathematica notations. This same strategy could be applied to teaching Python of course. Indeed, some of the notations are essentially the same, e.g. this one about map(): http://www.mathematica.co.kr/mathcomm/20_definitionviz/map.html -- the apply() one pertains as well: http://www.mathematica.co.kr/mathcomm/20_definitionviz/apply.html Yes, these are Flash animations. Kirby From louis.bertrand@durhamc.on.ca Thu Feb 7 22:15:45 2002 From: louis.bertrand@durhamc.on.ca (Louis Bertrand) Date: Thu, 7 Feb 2002 17:15:45 -0500 Subject: [Edu-sig] Python for MS .NET? Message-ID: <200202072215.g17MFjY0009490@rebellion.durhamc.on.ca> --------------Boundary-00=_9IO60I0UPCMR2RMX3BTU Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello all, I have no idea where to look=20 for the answer to this request=20 (see forwarded message below). I didn't see anything in the PEPs, and the only IDE for Python seems to be IDLE. Are there any hints that Python=20 can be used as a language for .NET? Where else could I look? Thanks --Louis ---------- Forwarded Message ---------- Subject: Eiffel Is Available for VS.NET Date: Thu, 7 Feb 2002 08:04:02 -0500 An evaluation version of Eiffel is available for VS.NET. It appears to be a much bigger download than the Cobol download that I tried yesterday. Does anyone know of any other languages currently available in VS .NET? The proliferation of these extra languages and support by companies like Rationale may make VS .NET a must have for next September. I think that we should have a mini-seminar or workshop in May-June where each one of us could look at a .NET feature and help train each other. Other computer faculty should be invited to participate. John do you have a list of all of the programming related professors at the college? <|:-) Arthur J. Smith ------------------------------------------------------- --=20 Louis Bertrand School of Technology, Durham College Oshawa, ON, Canada +1.905.721.3111 x2468 --------------Boundary-00=_9IO60I0UPCMR2RMX3BTU Content-Type: text/html; charset="us-ascii"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable

An evaluation version of Eiffel is available for VS.NET.  It appears to be = a much bigger download than the Cobol download that I tried yesterday.  Does anyone know of any other = languages currently available in VS .NET?

 

The proliferation of these extra languages and = support by companies like Rationale may make VS .NET a must have for next = September.  I think that we should have a mini-seminar or workshop in May-June where each one of us could look at = a .NET feature and help train each other.  Other computer faculty should be invited to participate.  John do you have a list of all = of the programming related professors at the college?<= /p>

 

<|:-)  = Arthur J. Smith

 

--------------Boundary-00=_9IO60I0UPCMR2RMX3BTU-- From gritsch@iue.tuwien.ac.at Thu Feb 7 23:17:21 2002 From: gritsch@iue.tuwien.ac.at (Markus Gritsch) Date: Fri, 08 Feb 2002 00:17:21 +0100 Subject: [Edu-sig] Python for MS .NET? References: <200202072215.g17MFjY0009490@rebellion.durhamc.on.ca> Message-ID: <3C630B01.8070908@iue.tuwien.ac.at> Louis Bertrand wrote: > Hello all, > > I have no idea where to look > for the answer to this request > (see forwarded message below). > I didn't see anything in the PEPs, > and the only IDE for Python seems > to be IDLE. > > Are there any hints that Python > can be used as a language for .NET? > > Where else could I look? ActiveState provides a commercial solution: http://www.activestate.com/Products/Visual_Python/ Markus From mats@laplaza.org Fri Feb 8 01:26:37 2002 From: mats@laplaza.org (Mats Wichmann) Date: Thu, 07 Feb 2002 18:26:37 -0700 Subject: [Edu-sig] Python for MS .NET? In-Reply-To: <3C630B01.8070908@iue.tuwien.ac.at> References: <200202072215.g17MFjY0009490@rebellion.durhamc.on.ca> Message-ID: <5.1.0.14.1.20020207182424.01f0ba38@204.151.72.2> >> Are there any hints that Python >> can be used as a language for .NET? >> >> Where else could I look? > > >ActiveState provides a commercial solution: > >http://www.activestate.com/Products/Visual_Python/ Well, no, they don't, at least not now. They were involved in a project, paid for by MS if I understand, to develop some demo/proof of concept stuff. There's no commercial committment right now, and some of their Python developers have been dumped (see the comp.lang.python archives for some notes from Mark Hammond on this). From csmith@blakeschool.org Sun Feb 10 23:21:35 2002 From: csmith@blakeschool.org (Christopher Smith) Date: Sun, 10 Feb 2002 17:21:35 -0600 Subject: [Edu-sig] making an alias of a folder Message-ID: I think I put this request out before but haven't received any replies...perhaps there is someone new on the list that could help: Does anyone have a piece of code that successfully makes an alias of a folder on the MacOS? Even if you know how to do this in RealBasic or VisualBasic and could send me that code snippet I think it would be useful. I'm trying to complete a patch to a file copying routine. /c From dyoo@hkn.eecs.berkeley.edu Mon Feb 11 03:23:11 2002 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Sun, 10 Feb 2002 19:23:11 -0800 (PST) Subject: [Edu-sig] Re: [Tutor] making an alias of a folder In-Reply-To: Message-ID: On Sun, 10 Feb 2002, Christopher Smith wrote: > I think I put this request out before but haven't received any > replies...perhaps there is someone new on the list that could help: > > Does anyone have a piece of code that successfully makes an alias of a > folder on the MacOS? Hello! First, I'd better admit I'm clueless about this one... *grin* You might be able to find something in here: http://www.python.org/doc/current/mac/mac.html I don't have a Macintosh available at the moment, so I can't test this, but I believe that the macfs.NewAliasMinimalFromFullPath() is the function that you're looking for: http://www.python.org/doc/current/mac/module-macfs.html Good luck to you! From jack@oratrix.com Mon Feb 11 10:29:04 2002 From: jack@oratrix.com (Jack Jansen) Date: Mon, 11 Feb 2002 11:29:04 +0100 Subject: [Edu-sig] Re: [Pythonmac-SIG] Re: [Tutor] making an alias of a folder In-Reply-To: Message-ID: <2C5ABB21-1EDA-11D6-8176-0030655234CE@oratrix.com> I was going to point you to the convenience routine macostools.mkalias(src, dst), until I tried it and noticed it didn't work for folders:-( I've filed a sourceforge bug report (#515830), you may want to monitor this if you're interested in when this is fixed. On Monday, February 11, 2002, at 04:23 , Danny Yoo wrote: > On Sun, 10 Feb 2002, Christopher Smith wrote: > >> I think I put this request out before but haven't received any >> replies...perhaps there is someone new on the list that could help: >> >> Does anyone have a piece of code that successfully makes an alias of a >> folder on the MacOS? > > Hello! > > First, I'd better admit I'm clueless about this one... *grin* You might > be > able to find something in here: > > http://www.python.org/doc/current/mac/mac.html > > I don't have a Macintosh available at the moment, so I can't test this, > but I believe that the macfs.NewAliasMinimalFromFullPath() is the > function > that you're looking for: > > http://www.python.org/doc/current/mac/module-macfs.html > > > Good luck to you! > > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -- - Jack Jansen http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - From csmith@blakeschool.org Mon Feb 11 15:09:35 2002 From: csmith@blakeschool.org (Christopher Smith) Date: Mon, 11 Feb 2002 09:09:35 -0600 Subject: [Edu-sig] Re: making an alias of a folder In-Reply-To: References: Message-ID: Danny Yoo writes: > >I don't have a Macintosh available at the moment, so I can't test this, >but I believe that the macfs.NewAliasMinimalFromFullPath() is the function >that you're looking for: > > http://www.python.org/doc/current/mac/module-macfs.html I looked at that and didn't initially think that it was going to help but your saying it might be the thing made me look again. Though I don't know if I've got everything right, I do have a routine now that will make an alias of a folder. I don't understand the "relative" option yet, though. Those more in the know about the mac toolbox may see other things that I don't know as well. :-) Until the macostools.makealias is fixed, this is a workaround. Thanks for the nudge, Danny. And thanks for filing a bug report, Jack. /c #### import macfs from Carbon import Res # # Doesn't yet handle the relative option; I'm not sure what this # means for an alias yet. # def mkfolderalias(src, dst, relative=None): """Create an alias to a folder""" alias = macfs.NewAliasMinimalFromFullPath(dst) dstfss = alias.Resolve()[0] Res.FSpCreateResFile(dstfss, 'MACS', 'fdrp', -1) # make it point at the src and update the resource # {see Mac Lib Modules; v 2.2; sect 2.4.2 Alias Objects} # If the source is itself an alias, the new alias # will point at the same thing that the src alias is # pointing at. If the src is *not* a folder it will then # still point at the file but the icon will be a folder # icon until it is updated by the Finder (e.g. after # double clicking on it in the Finder). # alias.Update(src) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) resource.AddResource('alis', 0, '') Res.CloseResFile(h) # turn it into an alias icon; before doing this the # folder icon will be "busy and in use by the system" # dstfss = macfs.FSSpec(dst) dstfinfo = dstfss.GetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.SetFInfo(dstfinfo) #### From urnerk@qwest.net Tue Feb 12 19:40:52 2002 From: urnerk@qwest.net (Kirby Urner) Date: Tue, 12 Feb 2002 11:40:52 -0800 Subject: [Edu-sig] New Python book In-Reply-To: Message-ID: <4.2.0.58.20020212113053.00c9d120@pop3.norton.antivirus> Greetings all: 'Python: How to Program' (2002, Prentice-Hall) is now available. It includes stuff on XHTML/CSS, XML, PyOpenGL, XML, interfacing with a database, CGI and more (even some stuff on 2.2 iterators and generators). It's designed as possible course text, with questions and exercises at the end of each chapter. Comes with CD, including the source code, Alice (multimedia package with Python API) and Apache web server. Kirby PS: I was a reviewer, doing testing and providing feedback on some of the chapters (one of many, see pg. LV). Just got my copy from the publisher yesterday. Dunno the sale price -- it's a 1300 page monster (plus CD) so probably in the $45-$60 range, judging from similar books. Wait, I should just check Amazon... yikes, $74. Well, like I say, it's a mighty thick tome. From paul@prescod.net Wed Feb 13 18:24:33 2002 From: paul@prescod.net (Paul Prescod) Date: Wed, 13 Feb 2002 10:24:33 -0800 Subject: [Edu-sig] Re: [PSF-Members] python domain References: <3C6AA634.B433175D@prescod.net> <200202131805.g1DI58D17306@pcp742651pcs.reston01.va.comcast.net> Message-ID: <3C6AAF61.787B3DDC@prescod.net> By the way, I own CP4E.org and cp4e.net. Happy to donate them to anyone who would use them for something Python and education related. I haven't bothered to make them aliases for the Python site because there didn't seem much point... Paul Prescod From todd@thewhittakers.org Fri Feb 15 18:00:42 2002 From: todd@thewhittakers.org (Todd Whittaker) Date: Fri, 15 Feb 2002 13:00:42 -0500 (EST) Subject: [Edu-sig] Executable pseudocode / executable flowcharts Message-ID: Hey all, I can make a good case in education for Python as a first language because, as everyone claims, it it executable pseudo-code. I know it. I believe it. I've made a case for it. But, where I work, our students need more than just pseudo-code. What we need is a tool that lets students create executable flowcharts as well. Yes, I know that most folks don't use flowcharts, that the belief is that they're outdated tools, pseudo-code is better, and so on. But, for visual learners, an executable flowchart can be a great tool (especially one that can be stepped through like a debugger, complete with watch windows). Does anyone know of such a tool? If not, would there be interest in making it? I'm thinking some nifty features could be: 1. Draw flowcharts with Python expressions and statements in the graphical boxes. 2. Export the flowcharts as Python code. 3. Import Python code into a graphical flowchart representation. 4. Step through flowchart execution one statement at a time and view an output window and variable watch windows at the same time. This works best for procedural programming, and I have no idea how to represent OOP in a flowchart. Thoughts? -- Todd ------------------------------------------------------------- Todd A. Whittaker mailto:todd@thewhittakers.org http://www.thewhittakers.org/~todd/ ------------------------------------------------------------- From jhrsn@pitt.edu Fri Feb 15 20:31:58 2002 From: jhrsn@pitt.edu (Jim Harrison) Date: Fri, 15 Feb 2002 15:31:58 -0500 Subject: [Edu-sig] Executable pseudocode / executable flowcharts In-Reply-To: Message-ID: > But, for visual learners, an executable flowchart can be a great tool > (especially one that can be stepped through like a debugger, complete with > watch windows). > > Does anyone know of such a tool? If not, would there be interest in making it? > I'm thinking some nifty features could be: Though it's not Python, the best implementation of this sort of thing that I've come across was Prograph, a completely visual language of flow diagrams that compiled directly to executable code. The IDE had the best debugger I've ever seen--stepping through the diagrams with a color change marking the execution point, all data values visible and editable, with arbitrary roll back and roll forward. Prograph was originally Mac-only, though now it appears to be Windows-only. See www.pictorius.com/prograph. > This works best for procedural programming, and I have no idea how to > represent OOP in a flowchart. It may be a bit heavy-duty for what you want, but you could look into the Unified Modeling Language (UML), which collects together several styles of flowcharting, process modeling and class diagramming in a generally OO framework. Note that this is just a set of conventions for using diagrams in software design, not a language that's executable in any sense. However, there are a number of commercial CASE tools that can create code from the diagrams, and there's a nice paper on UML and open-source at: http://www.linuxgazette.com/issue67/gilliam.html Jim Harrison Univ. of Pittsburgh From jhrsn@pitt.edu Fri Feb 15 20:41:20 2002 From: jhrsn@pitt.edu (Jim Harrison) Date: Fri, 15 Feb 2002 15:41:20 -0500 Subject: [Edu-sig] Executable pseudocode (more) In-Reply-To: Message-ID: The other tool I was trying to think of is DOME, which might allow you to come close to your goal of building relatively simple diagrams that could be executable (in the DOME environment), as a prelude to pure text coding. http://www.htc.honeywell.com/dome/description.htm DOME is written in smalltalk and none of the tools I've seen are particularly oriented to Python, though I think Python would be a pretty good match for such a tool. Jim Harrison Univ. of Pittsburgh From dyoo@hkn.eecs.berkeley.edu Fri Feb 15 21:20:37 2002 From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo) Date: Fri, 15 Feb 2002 13:20:37 -0800 (PST) Subject: [Edu-sig] Executable pseudocode / executable flowcharts In-Reply-To: Message-ID: On Fri, 15 Feb 2002, Todd Whittaker wrote: > > Hey all, > > I can make a good case in education for Python as a first language > because, as everyone claims, it it executable pseudo-code. I know it. I > believe it. I've made a case for it. But, where I work, our students > need more than just pseudo-code. What we need is a tool that lets > students create executable flowcharts as well. > > Yes, I know that most folks don't use flowcharts, that the belief is that > they're outdated tools, pseudo-code is better, and so on. But, for visual > learners, an executable flowchart can be a great tool (especially one that > can be stepped through like a debugger, complete with watch windows). > > Does anyone know of such a tool? If not, would there be interest in making > it? I'm thinking some nifty features could be: You may be interested in ViPEr: http://www.scripps.edu/~sanner/html/papers/IPC02.pdf This looks like a very facinating project that allows people to effectively program using visual flowcharts. From todd@thewhittakers.org Sat Feb 16 01:36:40 2002 From: todd@thewhittakers.org (Todd Whittaker) Date: Fri, 15 Feb 2002 20:36:40 -0500 (EST) Subject: [Edu-sig] Executable pseudocode / executable flowcharts In-Reply-To: Message-ID: Thanks for the links. I found a paper today that shows roughly what I'm looking for, but I can't seem to actually find the software. For those interested, here's the link: http://fie.engrng.pitt.edu/fie98/papers/1107.pdf It has screen shots of a package that lets students create a top down design that is then fleshed out with each method as an executable flowchart. It's called FLINT (for FLowchart INTerpreter). Their data suggests that there is a higher level of comprehension when programming is taught this way over a plain-old code way. When it comes to Object Oriented Programming (i.e. once you're past the methods-are-procedural-code roadblock), I've really liked the approach BlueJ has taken. But, that's a Java thing... http://www.bluej.org/ -- Todd ------------------------------------------------------------- Todd A. Whittaker mailto:todd@thewhittakers.org http://www.thewhittakers.org/~todd/ ------------------------------------------------------------- From mascher@crg.ha.nw.schule.de Sun Feb 17 13:25:25 2002 From: mascher@crg.ha.nw.schule.de (Christian Mascher) Date: Sun, 17 Feb 2002 14:25:25 +0100 Subject: [Edu-sig] Re: executable flowcharts--nsd-editor References: Message-ID: <3C6FAF45.FF78696D@gmx.de> > From: Todd Whittaker > To: Python in education > Subject: [Edu-sig] Executable pseudocode / executable flowcharts > > Hey all, > > I can make a good case in education for Python as a first language > because, as everyone claims, it it executable pseudo-code. I know it. I > believe it. I've made a case for it. But, where I work, our students > need more than just pseudo-code. What we need is a tool that lets > students create executable flowcharts as well. At http://www-iiuf.unifr.ch/sde/projects/kalt/NSD.html there is a small tool which lets you draw nassi-shneiderman diagrams and exports them to a file with pascal or c-code. I think this is really a neat little program, useful when teaching procedural programming at introductory level (control structures). Too bad it isn't geared for python where the translation between code and the nassi-shneiderman-diagram is very transparent due to the simple code formatting rules of python. If I had the time, I would pick something similar as a programming project in python. With such an editor you could also show your students that at the level of procedures python and pascal (and C, ...) don't differ much, its all the same kind of basic structure. I've also seen that for some beginners a flowchart is a great help in understanding the nature of an algorithm. Christian Mascher From urnerk@qwest.net Mon Feb 18 18:26:13 2002 From: urnerk@qwest.net (Kirby Urner) Date: Mon, 18 Feb 2002 10:26:13 -0800 Subject: [Edu-sig] Executable pseudocode / executable flowcharts In-Reply-To: Message-ID: <4.2.0.58.20020218100128.00abadf0@pop3.norton.antivirus> At 01:00 PM 2/15/2002 -0500, Todd Whittaker wrote: >Yes, I know that most folks don't use flowcharts, that >the belief is that they're outdated tools, pseudo-code is >better, and so on. But, for visual learners, an executable >flowchart can be a great tool (especially one that can be >stepped through like a debugger, complete with watch windows). Although not exactly what you have in mind, the Lego Mindstorms system is good for children and adults with no previous programming experience, in allowing the construction of programs as flowcharts. http://mindstorms.lego.com/ In the GUI, you drag canned actions (forward, turn left) as icons and sequence them vertically (called a "stack"). The canned actions come with tabs which open up wizards allowing some user-customizable parameters to be set. You can group sequences and give them names, at which point they condense into single blocks and list in the "My Blocks" palette (user-defined functions). You can sandwich blocks inside of repeat loops (Repeat Forever, Repeat Until etc.), define variables, insert conditional branches. Once you've defined a stack, you download it via infrared light beam to the RCX, a brick-shaped unit with sensor inputs and power outputs, to which motors are connected. Although there's no debugger per se, individual blocks can be "tried" (test download and execute). In a lot of ways, the experience from a kid's point of view is similar to controlling a graphical turtle through Logo, except here the "turtle" is a physical device, and the whole engineering angle of building robust "robots" is brought into the learning experience. On screen, a program is an executable flowchart (savable of course). A curriculum might start with Mindstorms at the 4th grade level, then move to a more fully developed concept of a programming language. The O'Reilly book introduces NQC (not quite C) as a way to program the RCX, and moves on to a version of FORTH. Kids would already have the algorithm-as-flowchart exposure through the introductory GUI. http://www.oreilly.com/catalog/lmstorms/desc.html Agilent has a product (looks like a reincarnation of what was formerly HP VEE) that allows graphical programming by hooking boxes together, using conditional branching. The same idea of user-definable parameters per box is implemented. Here the boxes may contain signal processing algorithms, such as a Fourier Transform or something. For many students, this would be a logical follow-on to the Mindstorms curriculum, as the robot has touch, light and other sensors, to which the algorithms respond. The VEE product is likewise all about processing sensor data in the lab. There's a freely downloadable trial version: http://www.get.agilent.com/gpinstruments/products/vee/download.shtml Kirby From urnerk@qwest.net Tue Feb 19 17:04:33 2002 From: urnerk@qwest.net (Kirby Urner) Date: Tue, 19 Feb 2002 09:04:33 -0800 Subject: [Edu-sig] Another example of Python at work In-Reply-To: <200202191428.JAA10348@birds.us.itd.umich.edu> Message-ID: <4.2.0.58.20020219085519.01acfe70@pop3.norton.antivirus> Just to toss out another example of a project wherein Python is proving very useful as a "glue language", I offer my: http://www.inetarena.com/~pdx4d/ocn/sphpacking.html What's going on here is we have this Java applet that packs spheres in a particular way. We want to use its data to feed another free software package called Qhull, and we want to view the results using free rendering software (Povray) and VRML. So Python comes in and does all the mediation between the apps, reading sphere data, doing computations, passing data out to Qhull, reading it back in, and so on. It's the kind of thing that you want to do fairly quickly, and without trying to memorialize the whole process in some perfect code. A little worse (than perfect) is better in this case. Also, thanks to object-orientation, it's natural to define "Ball" objects which correspond to the balls in the packing. These get properties and methods related to finding all nearby neighbors, and for rendering the results. Python fits the problem, because it fits your brain (or mine at least). Kirby From csmith@blakeschool.org Wed Feb 20 20:38:44 2002 From: csmith@blakeschool.org (Christopher Smith) Date: Wed, 20 Feb 2002 14:38:44 -0600 Subject: [Edu-sig] style question Message-ID: I have a question of style and am wondering if you would consider giving some feedbakc. Let's say you have a task of finding out how many of 5 positive integer numbers (a-e) are even. Which (if either) of the two codes would be preferred: # {option A} odd=a%2+b%2+c%2+d%2+e%2 even=5-odd # {option B} if a%2==0: even = even + 1 if b%2==0: even = even + 1 if c%2==0: even = even + 1 if d%2==0: even = even + 1 if e%2==0: even = even + 1 odd = 5 - even Is option A guilty of relying on the "side effect" of mod 2 being a 1 or zero or is this a desireable/understandable use of this function's return value? /c From urnerk@qwest.net Wed Feb 20 21:59:13 2002 From: urnerk@qwest.net (Kirby Urner) Date: Wed, 20 Feb 2002 13:59:13 -0800 Subject: [Edu-sig] style question In-Reply-To: Message-ID: <4.2.0.58.20020220135745.01af8140@pop3.norton.antivirus> > Which (if either) of the two >codes would be preferred: I agree with Danny that a list-based approach would be better: from operator import add def check(testlist): return reduce(add,[i%2==0 for i in testlist]) >>> check([1,4,5,9,3,8,7]) 2 Kirby From alan.gauld@bt.com Thu Feb 21 11:45:41 2002 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 21 Feb 2002 11:45:41 -0000 Subject: [Edu-sig] RE: [Tutor] style question Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C3B6@mbtlipnt02.btlabs.bt.co.uk> > some feedbakc. Let's say you have a task of finding out how many of 5 > positive integer numbers (a-e) are even. Which (if either) of the two > codes would be preferred: > > # {option A} > odd=a%2+b%2+c%2+d%2+e%2 > even=5-odd Yech! I don't like this under any circumstance. If I really wanted to do it in two lines I'd try something like: >>> count = 0 >>> L = [a,b,c,d,e] >>> for n in L: if n%2: count += 1 > # {option B} > if a%2==0: > even = even + 1 > if b%2==0: > even = even + 1 > if c%2==0: > even = even + 1 > if d%2==0: > even = even + 1 > if e%2==0: > even = even + 1 This is the same as above but writing the loop longhand... > Is option A guilty of relying on the "side effect" of mod 2 > being a 1 or zero or is this a desireable/understandable > use of this function's return It's an acceptable use but just plain obtuse. The minor gain in performance over the loop doesn't justify the loss of readability IMHO. Alan g From dajoy@operamail.com Thu Feb 21 05:14:31 2002 From: dajoy@operamail.com (Daniel Ajoy) Date: Thu, 21 Feb 2002 00:14:31 -0500 Subject: [Edu-sig] Re: Executable pseudocode / executable flowcharts In-Reply-To: Message-ID: <3C743BE7.76.167BB6C@localhost> Executable pseudocode / executable flowcharts (Kirby Urner) > Agilent has a product (looks like a reincarnation of what > was formerly HP VEE) that allows graphical programming by > hooking boxes together, using conditional branching. The > same idea of user-definable parameters per box is implemented. > Here the boxes may contain signal processing algorithms, > such as a Fourier Transform or something. This is also about boxes to represent programs: http://www.soe.berkeley.edu/~boxer/ "20 Reasons to use Boxer (Instead of Logo)" ftp://soe.berkeley.edu/pub/boxer/Distribution/20reasons.pdf Daniel From wilson@isis.visi.com Fri Feb 22 06:07:56 2002 From: wilson@isis.visi.com (Tim Wilson) Date: Fri, 22 Feb 2002 00:07:56 -0600 (CST) Subject: [Edu-sig] IDLE problems with Tkinter Message-ID: Hi everyone, My students have used IDLE for all their editing to this point. Now we're getting to the point of playing with Tkinter a bit and I find that many, if not all, of the Tkinter apps I try don't exit cleaning and end up hanging IDLE. We're using Python 2.2 on Win95, but the same thing happend with Win98. Running the programs from the DOS shell seems to work fine. Is this a known problem with IDLE? I'm including a short script below that exemplifies the problem. The code is from Wesley Chun's Core Python book. from Tkinter import * def resize(ev=None): label.config(font='Helvetica -%d bold' % scale.get()) top = Tk() top.geometry('250x150') label= Label(top, text="Hello World!", font='Helvetica -12 bold') label.pack(fill=Y, expand=1) scale = Scale(top, from_=10, to=40, orient=HORIZONTAL, command=resize) scale.set(12) scale.pack(fill=X, expand=1) quit = Button(top, text="Quit", command=top.quit, activebackground='red', activeforeground='white') quit.pack() mainloop() Thanks for any input anyone can provide. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | | http://linux.com From schoen@loyalty.org Fri Feb 22 06:46:11 2002 From: schoen@loyalty.org (Seth David Schoen) Date: Thu, 21 Feb 2002 22:46:11 -0800 Subject: [Edu-sig] RE: [Tutor] style question In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C3B6@mbtlipnt02.btlabs.bt.co.uk> References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C3B6@mbtlipnt02.btlabs.bt.co.uk> Message-ID: <20020222064611.GC23685@zork.net> alan.gauld@bt.com writes: > > some feedbakc. Let's say you have a task of finding out how many of 5 > > positive integer numbers (a-e) are even. Which (if either) of the two > > codes would be preferred: > > > > # {option A} > > odd=a%2+b%2+c%2+d%2+e%2 > > even=5-odd > > Yech! I don't like this under any circumstance. > If I really wanted to do it in two lines I'd try something like: > > >>> count = 0 > >>> L = [a,b,c,d,e] > >>> for n in L: > if n%2: count += 1 > > > # {option B} > > if a%2==0: > > even = even + 1 > > if b%2==0: > > even = even + 1 > > if c%2==0: > > even = even + 1 > > if d%2==0: > > even = even + 1 > > if e%2==0: > > even = even + 1 I like lambda and filter a lot: L = [a,b,c,d,e] even = len(L) - len(filter(lambda x: x%2, L)) Some people prefer "x&1" instead of "x%2". "~x&1" is probably the shortest Python expression for "x is even", so you could write even = len(filter(lambda x: ~x&1, L)) -- Seth David Schoen | Reading is a right, not a feature! http://www.loyalty.org/~schoen/ | -- Kathryn Myronuk http://vitanuova.loyalty.org/ | From delza@mac.com Fri Feb 22 07:08:36 2002 From: delza@mac.com (Dethe Elza) Date: Thu, 21 Feb 2002 23:08:36 -0800 Subject: [Edu-sig] IDLE problems with Tkinter In-Reply-To: Message-ID: I think that the version of IDLE that comes with Python doesn't run programs in their own thread. This was fixed in the version which comes with VPython, and lead to the Idle Fork. VPython: http://www.vpython.org/ Idle Fork: http://idlefork.sourceforge.net/ Note: I still do my python development with vim, not an IDE, so my comments could be way off base here. --Dethe On Thursday, February 21, 2002, at 10:07 PM, Tim Wilson wrote: > Hi everyone, > > My students have used IDLE for all their editing to this point. Now > we're getting to the point of playing with Tkinter a bit and I find that > many, if not all, of the Tkinter apps I try don't exit cleaning and end > up hanging IDLE. We're using Python 2.2 on Win95, but the same thing > happend with Win98. Running the programs from the DOS shell seems to > work fine. > > Is this a known problem with IDLE? I'm including a short script below > that exemplifies the problem. The code is from Wesley Chun's Core Python > book. > > from Tkinter import * > > def resize(ev=None): > label.config(font='Helvetica -%d bold' % scale.get()) > > top = Tk() > top.geometry('250x150') > > label= Label(top, text="Hello World!", font='Helvetica -12 bold') > label.pack(fill=Y, expand=1) > > scale = Scale(top, from_=10, to=40, orient=HORIZONTAL, command=resize) > scale.set(12) > scale.pack(fill=X, expand=1) > > quit = Button(top, text="Quit", command=top.quit, > activebackground='red', activeforeground='white') > quit.pack() > > mainloop() > > > Thanks for any input anyone can provide. > > -Tim > > -- > Tim Wilson | Visit Sibley online: | Check out: > Henry Sibley HS | http://www.isd197.org | http://www.zope.com > W. St. Paul, MN | | http://slashdot.org > wilson@visi.com | | http://linux.com > > > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Dethe Elza (delza@burningtiger.com) Chief Mad Scientist Burning Tiger Technologies (http://www.burningtiger.com) Weblog: http://livingcode.manilasites.com/ From djrassoc01@mindspring.com Fri Feb 22 14:40:31 2002 From: djrassoc01@mindspring.com (Dr. David J. Ritchie, Sr.) Date: Fri, 22 Feb 2002 08:40:31 -0600 Subject: [Edu-sig] IDLE problems with Tkinter References: Message-ID: <3C76585F.D3952584@mindspring.com> In regard to what Tim Wilson wrote: > ...Now > we're getting to the point of playing with Tkinter a bit and I find that > many, if not all, of the Tkinter apps I try don't exit cleaning and end > up hanging IDLE. We're using Python 2.2 on Win95, but the same thing > happend with Win98. Running the programs from the DOS shell seems to > work fine. > > Is this a known problem with IDLE? > > ... Yes, it is a known problem (to me anyway). In the release notes for Python on the Mac there is the following info. I recommend you check the release notes on your installation. ---------------------------- Known problems -------------- This list is probably incomplete, more problems may be listed on the MacPython homepage, http://www.cwi.nl/~jack/macpython.html. ... - The IDE and Tkinter do not work together. Run tkinter programs under PythonInterpreter. - Tkinter file events do not work, unless you have opened the file through Tcl (but then you cannot access it from Python). ... - PythonInterpreter used interactively will eat a lot of processor cycles. You should use PythonIDE for interactive work and PythonInterpreter for scripts only. This is especially true under OSX. ------------------------------- I and my kids in my Middle School club where we run Python on Windows NT tend to use the editor for what I think is IDLE and then run the script using the run option under the edit menu. That seems to work ok for the kinds of Tkinter and Python things we have been doing. We don't use the interactive window at all. Perhaps, we just haven't run into things yet though. > Thanks for any input anyone can provide. > > -Tim > > -- > Tim Wilson | Visit Sibley online: | Check out: > Henry Sibley HS | http://www.isd197.org | http://www.zope.com > W. St. Paul, MN | | http://slashdot.org > wilson@visi.com | | http://linux.com You are welcome... --D. -- Dr. David J. Ritchie, Sr. djrassoc01@mindspring.com http://home.mindspring.com/~djrassoc01/ From glingl@aon.at Fri Feb 22 21:49:55 2002 From: glingl@aon.at (Gregor Lingl) Date: Fri, 22 Feb 2002 22:49:55 +0100 Subject: [Edu-sig] IDLE problems with Tkinter References: Message-ID: <007301c1bbea$dd637a30$1664a8c0@mega> > > Is this a known problem with IDLE? > Yes. Despite of this I use IDLE with my students interactivly. Here an example session: >>> from Tkinter import * >>> root = Tk() >>> cv = Canvas(root, width=300, height=250, bg='yellow') >>> cv.pack() >>> cv.pack_forget() >>> cv.pack(expand=1, fill=BOTH) >>> from Canvas import * >>> r = Rectangle(cv, 50,20, 250,220) >>> k = Oval(cv, 70,40,230,200, fill='pink') >>> l1 = Line(cv, 120,150,180,150, fill='red', width=6) >>> l1.move(0,20) >>> l1.coords() [120.0, 170.0, 180.0, 170.0] >>> l2=Line(cv,150,120,160,162) >>> l2['fill']='brown' >>> l2['width']=4 >>> e1=Oval(cv,110,90,140,105,fill='blue') >>> e2=Oval(cv,159,89,191,106,fill='lightblue') >>> k['fill']='orange' >>> Works fine and you can observe the construction of the graphics on the canvas. (In a similar way it's possible to add Buttons and other widgets etc.) Students (age of 15) have much fun with this approach. For them this is a way to explore Tkinter, (which is very poorly documented in German.) To turn it into a program we copy (as usual) the appropriate statements into an edit-window of IDLE and in this case we got: from Tkinter import * from Canvas import * root = Tk() cv = Canvas(root, width=300, height=250, bg='yellow') cv.pack(expand=1, fill=BOTH) r = Rectangle(cv, 50,20, 250,220) k = Oval(cv, 70,40,230,200, fill='orange') l1 = Line(cv, 120,170,180,170, fill='red', width=6) l2=Line(cv,150,120,160,162) l2['fill']='brown' l2['width']=4 e1=Oval(cv,110,90,140,105,fill='blue') e2=Oval(cv,159,89,191,106,fill='lightblue') this can be run as usual via File/Save and Edit/Run script Another Tk-window pops up and we see our graphics again. To run this program as a script one only has to add root.mainloop() Shortly this means: as long as there is no mainloop() in your script it runs correctly from IDLE. If later we want to use it as a script, we add mainloop() Hope you found this interesting Gregor Lingl From lha2@columbia.edu Fri Feb 22 23:04:55 2002 From: lha2@columbia.edu (Lloyd Hugh Allen) Date: Fri, 22 Feb 2002 18:04:55 -0500 Subject: [Edu-sig] Re: Tkinter and IDLE References: Message-ID: <3C76CE97.2ACB4E7B@mail.verizon.net> I seem to recall someone on the tutor list suggesting way back that if you comment out the mainloop() of a Tkinter program, it will (usually) work fine under IDLE. The issue is that IDLE uses Tkinter itself, and python gets confused when two mainloop()s are running (rather, gets confused when you try to shut one of them down). From jeff@elkner.net Sun Feb 24 20:53:18 2002 From: jeff@elkner.net (Jeffrey Elkner) Date: 24 Feb 2002 15:53:18 -0500 Subject: [Edu-sig] Analyzing algorithms... Message-ID: <1014583999.1496.12.camel@robeson> After attending Pai Chou's wonderful presentation, "Algorithm Education in Python" at Python10, I got permission from the instructor of an algorithms course I am currently taking to do our programming assignments in Python (after first assuring him that they would not be difficult to read ;-) Our first assignment is to implement merge and heap sort and then to compare them empirically as to the number of assignments and comparisons made by each. I've written the sorts. Does anyone have any suggestions as to the best way to do the empirical analysis? Is there a better way than just creating counters and then littering my code with increment statements? Please let me know if you have any ideas? Thanks! jeff elkner yorktown high school arlington, va From urnerk@qwest.net Sun Feb 24 21:35:38 2002 From: urnerk@qwest.net (Kirby Urner) Date: Sun, 24 Feb 2002 13:35:38 -0800 Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <1014583999.1496.12.camel@robeson> Message-ID: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> > >I've written the sorts. Does anyone have any suggestions as to the best >way to do the empirical analysis? Is there a better way than just >creating counters and then littering my code with increment statements? > >Please let me know if you have any ideas? I'd probably make the elements to be sorted instances of some object, override the comparison operators, and build a counter into their invocation. Something similar could be done with assignment, where you use an object method to store an element, versus a simple =. E.g.: >>> class Element: def __init__(self,val): self.value = val self.comp = 0 def __repr__(self): return str(self.value) def __eq__(self,other): self.comp += 1 other.comp += 1 return self.value==other.value def __gt__(self,other): self.comp += 1 other.comp += 1 return self.value>other.value def __lt__(self,other): self.comp += 1 other.comp += 1 return self.value=other.value >>> a = Element(1) >>> b = Element(2) >>> a>> a==b 0 >>> a>=b 0 >>> a<=b 1 >>> a>b 0 >>> a.comp # internal counter knows how many comparisons 5 >>> b.comp # ditto Kirby From tim.one@comcast.net Sun Feb 24 22:45:23 2002 From: tim.one@comcast.net (Tim Peters) Date: Sun, 24 Feb 2002 17:45:23 -0500 Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <1014583999.1496.12.camel@robeson> Message-ID: [Jeffrey Elkner] > After attending Pai Chou's wonderful presentation, "Algorithm Education > in Python" at Python10, I got permission from the instructor of an > algorithms course I am currently taking to do our programming > assignments in Python (after first assuring him that they would not be > difficult to read ;-) > > Our first assignment is to implement merge and heap sort and then to > compare them empirically as to the number of assignments and comparisons > made by each. > > I've written the sorts. Does anyone have any suggestions as to the best > way to do the empirical analysis? Is there a better way than just > creating counters and then littering my code with increment statements? That's what I usually do, but recently a semi-maddening semi-wonderful alternative became available via Tools/scripts/trace.py (in your Python distribution). The maddening part is that it's almost impossible to figure out how to use it: the docs (consisting of a --help message) talk about many options, but there's no overview, and no explantion of what the (non-option) arguments are supposed to be. So here's just-about simplest-possible use explained via example. Here's a file with a poor sort function: C:\Python22>type bubblesort.py def bubble(a): n = len(a) changed = 1 while changed: changed = 0 for i in xrange(n-1): if a[i] > a[i+1]: a[i], a[i+1] = a[i+1], a[i] changed = 1 n -= 1 import random a = range(20) random.shuffle(a) print a bubble(a) print a Now I run it, just to make sure it works: C:\Python22>python bubblesort.py [14, 9, 7, 5, 16, 13, 1, 10, 17, 3, 11, 19, 0, 18, 8, 2, 12, 4, 6, 15] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Now pass the file to trace.py with the "-c" option: C:\Python22>python Tools/scripts/trace.py -c bubblesort.py [8, 12, 0, 6, 11, 16, 4, 17, 7, 10, 18, 2, 1, 9, 15, 19, 13, 5, 3, 14] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] That took much longer to run, but it's worth it because of what happens next: it left behind a text file named bubblsort.cover, which *annotates* each source line with the number of times it was executed: C:\Python22>type bubblesort.cover 2: def bubble(a): 2: n = len(a) 1: changed = 1 18: while changed: 16: changed = 0 216: for i in xrange(n-1): 184: if a[i] > a[i+1]: 87: a[i], a[i+1] = a[i+1], a[i] 87: changed = 1 16: n -= 1 . 1: import random 1: a = range(20) 1: random.shuffle(a) 1: print a 1: bubble(a) 1: print a . C:\Python22> It *also* left behind a random.cover file in the Lib directory. Stopping (possibly) unwanted stuff like that is what some of the other options aim at. Note some odd things about the output; in typical use they don't really matter, but if you're after exact counts you have to be aware of them: What trace.py actually counts is the number of SET_LINENO opcodes executed. Because "def" is an executable statement in Python, the count on "def bubble(a)" is actually two: it gets counted once for the time the def statement is executed (which defines the function), and a second time for *calling* the "bubble" function. I can't account for why the count is also two on "n = lan(a)"; looks like a bug. The count on "while 1" is 1 larger than "it should be", because under the covers a special SETUP_LOOP opcode is generated to get the while-loop started, and is executed one per function call. It gets counted against the "while changed:" line because the closest preceding SET_LINENO opcode said the SETUP_LOOP is due to line #4 in the function. The count on the "for" loop is also too large for the same reason, but worse because its hidden SETUP_LOOP opcode is executed (and counted against the "for") once for each iteration of the outer while-loop. As a result, the count on "for" is 16 la rger than expected (it *should* be 16 larger than the count on "if a[i] > ...", not 32 larger). The counts on the "plain old lines" within the loops are on the nose, though, and that's what's really important. Good luck! From jeff@elkner.net Sun Feb 24 23:25:49 2002 From: jeff@elkner.net (Jeffrey Elkner) Date: 24 Feb 2002 18:25:49 -0500 Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> References: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> Message-ID: <1014593149.1496.91.camel@robeson> Wow! Two very helpful replies within two hours on a Sunday afternoon. This list rocks! Thanks Kirby and Tim, I'm all set. jeff From gherman@darwin.in-berlin.de Mon Feb 25 07:41:06 2002 From: gherman@darwin.in-berlin.de (Dinu Gherman) Date: Mon, 25 Feb 2002 08:41:06 +0100 (CET) Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <1014593149.1496.91.camel@robeson> References: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> <1014593149.1496.91.camel@robeson> Message-ID: <1014622866.3c79ea92787d3@webmail.in-berlin.de> Jeffrey Elkner : > Wow! Two very helpful replies within two hours on a Sunday > afternoon. > > This list rocks! > > Thanks Kirby and Tim, I'm all set. > > jeff Sorry, I'm late, but I'll add a link here to one of the many sites doing animated algorithms which I find even more impressive than creating lists of counters: http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html I used to know some cool demo comparing various sorting algorithms simultaneously in the same fashion on the former NeXTSTEP system, but I was not able to find that quickly on the net... Regards, Dinu From glingl@aon.at Mon Feb 25 07:43:06 2002 From: glingl@aon.at (Gregor Lingl) Date: Mon, 25 Feb 2002 08:43:06 +0100 Subject: [Edu-sig] Analyzing algorithms... References: <1014583999.1496.12.camel@robeson> Message-ID: <001701c1bdd0$1087ff80$1664a8c0@mega> """ A friend of mine wrote a program not to analyze but to visualize different sorting algorithms. It's shown below. So it's a different topic, nevertheless I think it's interesting for educational purposes and fits into this context. (And there is a similar problem to that you mentioned (with displaying instead of counting), which perhaps could be solved in a better way than it is done below.) Run it. Maybe you enjoy it. Gregor """ ## Wolfgang.Urban@schule.at 02/2002 ## animierte Sortierung ## grün: aktueller Bereich in Arbeit ## rot: momentan beartbeitete Elemente ## mit commandline import random import time import string from Tkinter import * import sys ############################################################## ## Hilfsfunktionen ############################################################## ## range() mit inkludiertem letztem Wert def fullrange(a,b,step=1): if step>0: return range(a,b+1,step) else: return range(a,b-1,step) ## vertauscht zwei Listenelemente def swap(L,a,b): L[a],L[b] = L[b],L[a] ################################################################### ## Listen mit jeweils n Elemnenten zum Testen zur Verfügung stellen ## korrekt : bereits sortiert ## verkehrt: gestürzt ## konstant: lauter gleiche Werte ## dazu : richtig sortiert, aber letzte 'neu' Werte wiederum klein ################################################################### def listen(): return['korrekt','verkehrt','konstant','zufall','dazu'] def korrekt(n=10): return fullrange(1,n) def verkehrt(n=10): return fullrange(n,1,-1) def konstant(n=10): return [n/2]*n def zufall(n=10): liste = n*[0] for x in range(n): liste[x]=random.randrange(1,n+1) return liste def dazu(n=10,neu=3): return fullrange(1,n-neu)+fullrange(1,neu) ############################################################## ## die Sortieralgorithmen ############################################################## def methoden(): return ['bubble','bubbleclever','shaker','insertion','selection',\ 'shell','quick','heap','merge'] ############################################################## ## BubbleSort und Verwandte def bubble(): global L SHOW_bereich_quickest(0,len(L)-1) for x in range(len(L)): for z in fullrange(0,len(L)-2): SHOW_element1(z) SHOW_element2(z+1) if L[z]>L[z+1]: swap(L,z,z+1) SHOW_zeig([z,z+1]) def bubbleclever(): global L for oben in fullrange(len(L)-1,1,-1): SHOW_bereich_quickest(0,oben) for z in fullrange(0,oben-1): if L[z]>L[z+1]: SHOW_element1(z) SHOW_element2(z+1) swap(L,z,z+1) SHOW_zeig([z,z+1]) def shaker(): global L TRUE = 1 FALSE = 0 erstes = 0 letztes = len(L)-1 while TRUE: fertig = TRUE SHOW_bereich_quick(erstes,letztes) for i in fullrange(erstes,letztes-1): SHOW_element1(i) SHOW_element2(i+1) if L[i]>L[i+1]: swap(L,i,i+1) SHOW_zeig([i,i+1]) fertig = FALSE letztes = letztes-1 if fertig: return fertig = TRUE SHOW_bereich_quick(erstes,letztes) for i in fullrange(letztes,erstes+1,-1): SHOW_element1(i-1) SHOW_element2(i) if L[i-1]>L[i]: swap(L,i-1,i) SHOW_zeig([i-1,i]) fertig = FALSE erstes = erstes+1 if fertig: return ############################################################## ## Insertion Sort def insertion(): global L for stelle in range(1,len(L)): wert = L[stelle] i = stelle SHOW_element1(stelle) SHOW_bereich_quickest(0,stelle) while 1: SHOW_element1(i-1) if i==0: break if L[i-1]<=wert: break L[i] = L[i-1] # SHOW_bereich_quickest(i,stelle) SHOW_zeig([i,i-1]) i = i-1 L[i] = wert SHOW_zeig([stelle,i]) ############################################################## ## Selection Sort def selection(): global L for start in fullrange(0,len(L)-2): z = start SHOW_element1(start) SHOW_bereich(start,len(L)-1) for i in fullrange(start+1,len(L)-1): SHOW_element2(i) if L[i]1: step = step/3 for i in fullrange(step,len(L)-1): wert = L[i] stelle = i SHOW_bereich_quick(0,stelle) SHOW_element1(i) while 1: if stelleL[pos]): maximal = l else: maximal = pos if (r<=letzt) and (L[r]>L[maximal]): maximal = r if maximal != pos: swap(L,maximal,pos) SHOW_zeig([maximal,pos]) SHOW_element1(maximal) SHOW_element2(pos) repariere(L,maximal,letzt) def erzeugeHeap(L): letzt = len(L)-1 SHOW_bereich(0,letzt) for i in fullrange(len(L)/2,0,-1): repariere(L,i,letzt) ############################################################## ## Merge Sort def merge(): global L mergesort(L,L[:],0,len(L)-1) def mergesort(L,H,links,rechts): if links",die) cv.pack(expand=1,fill=NONE) cv.create_rectangle(offsetx-1,offsety, offsetx+anzahl*scalex-spacex+1,offsety-(anzahl+1)*scaley-1, fill="#d0d0d0", outline="#d0d0d0") L = zufall(anzahl) objNr = L[:] delay = deltime machalles() SHOW_zeigalles() cv.after(1500) cv.update() eval(name)() cv.coords(bereich,0,0,0,0) cv.coords(punkt1,0,0,0,0) cv.coords(punkt2,0,0,0,0) cv.update() #################### ## automatische Demo def do_demo(meth,deltime): global root root = Tk() root.title("Animierte Sortieralgorithmen") doit(meth,deltime) root.after(1000) root.update() root.destroy() def demo(): do_demo('bubble',5) do_demo('bubbleclever ',11) do_demo('shaker',15) do_demo('selection ',22) do_demo('insertion ',4) do_demo('shell',25) do_demo('quick',50) do_demo('heap',28) do_demo('merge',22) ############################################## ## Startroutine mit Übergabe von Kommandozeile def start(): global root cmdline = sys.argv[1:] meth="" if cmdline==[]: demo(); return else: for r in methoden(): if string.upper(r)==string.upper(cmdline[0]): meth=r break if meth=='': print "Algorithmus",cmdline[0],"unbekannt." sys.exit(1) deltime=15 if len(cmdline)>1: deltime=int(cmdline[1]) root = Tk() root.title("Animierte Sortieralgorithmen") doit(meth,deltime) root.after(1000) root.update() root.destroy() root.mainloop() ###################################################################### start() ----- Original Message ----- From: "Jeffrey Elkner" To: Sent: Sunday, February 24, 2002 9:53 PM Subject: [Edu-sig] Analyzing algorithms... > After attending Pai Chou's wonderful presentation, "Algorithm Education > in Python" at Python10, I got permission from the instructor of an > algorithms course I am currently taking to do our programming > assignments in Python (after first assuring him that they would not be > difficult to read ;-) > > Our first assignment is to implement merge and heap sort and then to > compare them empirically as to the number of assignments and comparisons > made by each. > > I've written the sorts. Does anyone have any suggestions as to the best > way to do the empirical analysis? Is there a better way than just > creating counters and then littering my code with increment statements? > > Please let me know if you have any ideas? > > Thanks! > > jeff elkner > yorktown high school > arlington, va > > > > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig > From Jason Cunliffe" <3C76CE97.2ACB4E7B@mail.verizon.net> Message-ID: <001301c1bdd6$0eaaa540$6401a8c0@jasonic> Phil Burke's Jsyn http://www.softsynth.com/jsyn/ JSyn allows you to develop interactive computer music programs in Java. You can run them as stand-alone applications, or as Applets in a web page using the JSyn Plugin. JSyn uses native methods written in 'C' to provide real-time audio synthesis for Java programmers. JSyn can be used to generate sound effects, audio environments, or music. JSyn is based on the traditional model of unit generators which can be connected together to form complex sounds. For example, you could create a wind sound by connecting a white noise generator to a low pass filter that is modulated by a random contour generator. check all the fine examples http://www.softsynth.com/jsyn/examples/ I guess this could a nice use of Jython too enjoy ./Jason From Jason Cunliffe" http://eamusic.dartmouth.edu/~book/ to be used with Jsyn http://www.softsynth.com/jsyn/plugins/ ./Jason ______________________________________________ Jason Cunliffe [NOMADICS: Director art+design] tel/fax: +1 718 422-1078 jasonic@nomadics.org N 43:00.000' W 074:31.875' ALT:1144 ft 84 Henry Street #3C Brooklyn NY 11201 USA From djrassoc01@mindspring.com Mon Feb 25 15:45:38 2002 From: djrassoc01@mindspring.com (Dr. David J. Ritchie, Sr.) Date: Mon, 25 Feb 2002 09:45:38 -0600 Subject: [Edu-sig] Analyzing algorithms... References: <1014583999.1496.12.camel@robeson> <001701c1bdd0$1087ff80$1664a8c0@mega> Message-ID: <3C7A5C1A.93A2192@mindspring.com> In regard to what Gregor Lingl wrote: > """ > A friend of mine wrote a program not to analyze but > to visualize different sorting algorithms. It's > shown below. > .... > > Run it. > Maybe you enjoy it. > Yes, it is very nice. Ran fine on a Mac under Python 2.1 with the Tkinter (and Python) that comes on the "Learning Python" book CD. At the end of the first sort (Bubble Sort) as run by the demo which is selected when the program is run with no arguments, I got a "handle already in use" (or some such thing) error. So, enclosed is a slightly revised version with things moved around to avoid that and which displays each sort in the demo in a different Toplevel window. Now, if someone wants to multi-thread the demo's so they show the sorts in the separate top level windows going on all simultaneous... ================================== ## Wolfgang.Urban@schule.at 02/2002 ## animierte Sortierung ## grün: aktueller Bereich in Arbeit ## rot: momentan beartbeitete Elemente ## mit commandline ## djrassoc01@mindspring.com 02/25/2002 ## each sort in its own separate toplevel window in demo ## no error after first demo sort. ## Have not tested non-null command line operation import random import time import string from Tkinter import * import sys ############################################################## ## Hilfsfunktionen ############################################################## ## range() mit inkludiertem letztem Wert def fullrange(a,b,step=1): if step>0: return range(a,b+1,step) else: return range(a,b-1,step) ## vertauscht zwei Listenelemente def swap(L,a,b): L[a],L[b] = L[b],L[a] ################################################################### ## Listen mit jeweils n Elemnenten zum Testen zur Verfügung stellen ## korrekt : bereits sortiert ## verkehrt: gestürzt ## konstant: lauter gleiche Werte ## dazu : richtig sortiert, aber letzte 'neu' Werte wiederum klein ################################################################### def listen(): return['korrekt','verkehrt','konstant','zufall','dazu'] def korrekt(n=10): return fullrange(1,n) def verkehrt(n=10): return fullrange(n,1,-1) def konstant(n=10): return [n/2]*n def zufall(n=10): liste = n*[0] for x in range(n): liste[x]=random.randrange(1,n+1) return liste def dazu(n=10,neu=3): return fullrange(1,n-neu)+fullrange(1,neu) ############################################################## ## die Sortieralgorithmen ############################################################## def methoden(): return ['bubble','bubbleclever','shaker','insertion','selection',\ 'shell','quick','heap','merge'] ############################################################## ## BubbleSort und Verwandte def bubble(): global L SHOW_bereich_quickest(0,len(L)-1) for x in range(len(L)): for z in fullrange(0,len(L)-2): SHOW_element1(z) SHOW_element2(z+1) if L[z]>L[z+1]: swap(L,z,z+1) SHOW_zeig([z,z+1]) def bubbleclever(): global L for oben in fullrange(len(L)-1,1,-1): SHOW_bereich_quickest(0,oben) for z in fullrange(0,oben-1): if L[z]>L[z+1]: SHOW_element1(z) SHOW_element2(z+1) swap(L,z,z+1) SHOW_zeig([z,z+1]) def shaker(): global L TRUE = 1 FALSE = 0 erstes = 0 letztes = len(L)-1 while TRUE: fertig = TRUE SHOW_bereich_quick(erstes,letztes) for i in fullrange(erstes,letztes-1): SHOW_element1(i) SHOW_element2(i+1) if L[i]>L[i+1]: swap(L,i,i+1) SHOW_zeig([i,i+1]) fertig = FALSE letztes = letztes-1 if fertig: return fertig = TRUE SHOW_bereich_quick(erstes,letztes) for i in fullrange(letztes,erstes+1,-1): SHOW_element1(i-1) SHOW_element2(i) if L[i-1]>L[i]: swap(L,i-1,i) SHOW_zeig([i-1,i]) fertig = FALSE erstes = erstes+1 if fertig: return ############################################################## ## Insertion Sort def insertion(): global L for stelle in range(1,len(L)): wert = L[stelle] i = stelle SHOW_element1(stelle) SHOW_bereich_quickest(0,stelle) while 1: SHOW_element1(i-1) if i==0: break if L[i-1]<=wert: break L[i] = L[i-1] # SHOW_bereich_quickest(i,stelle) SHOW_zeig([i,i-1]) i = i-1 L[i] = wert SHOW_zeig([stelle,i]) ############################################################## ## Selection Sort def selection(): global L for start in fullrange(0,len(L)-2): z = start SHOW_element1(start) SHOW_bereich(start,len(L)-1) for i in fullrange(start+1,len(L)-1): SHOW_element2(i) if L[i]1: step = step/3 for i in fullrange(step,len(L)-1): wert = L[i] stelle = i SHOW_bereich_quick(0,stelle) SHOW_element1(i) while 1: if stelleL[pos]): maximal = l else: maximal = pos if (r<=letzt) and (L[r]>L[maximal]): maximal = r if maximal != pos: swap(L,maximal,pos) SHOW_zeig([maximal,pos]) SHOW_element1(maximal) SHOW_element2(pos) repariere(L,maximal,letzt) def erzeugeHeap(L): letzt = len(L)-1 SHOW_bereich(0,letzt) for i in fullrange(len(L)/2,0,-1): repariere(L,i,letzt) ############################################################## ## Merge Sort def merge(): global L mergesort(L,L[:],0,len(L)-1) def mergesort(L,H,links,rechts): if links",die) cv.pack(expand=1,fill=NONE) cv.create_rectangle(offsetx-1,offsety, offsetx+anzahl*scalex-spacex+1,offsety-(anzahl+1)*scaley-1, fill="#d0d0d0", outline="#d0d0d0") L = zufall(anzahl) objNr = L[:] delay = deltime machalles() SHOW_zeigalles() cv.after(1500) cv.update() eval(name)() cv.coords(bereich,0,0,0,0) cv.coords(punkt1,0,0,0,0) cv.coords(punkt2,0,0,0,0) cv.update() #################### ## automatische Demo def do_demo(meth,deltime): global root wmeth = Toplevel(root) wmeth.title("Animierte Sortieralgorithmen: " + meth) doit(wmeth, meth, deltime) root.after(1000) root.update() wmeth.destroy() def demo(): do_demo('bubble',5) do_demo('bubbleclever ',11) do_demo('shaker',15) do_demo('selection ',22) do_demo('insertion ',4) do_demo('shell',25) do_demo('quick',50) do_demo('heap',28) do_demo('merge',22) ############################################## ## Startroutine mit Übergabe von Kommandozeile def start(): global root root = Tk() cmdline = sys.argv[1:] meth="" if cmdline==[]: demo() return else: for r in methoden(): if string.upper(r)==string.upper(cmdline[0]): meth=r break if meth=='': print "Algorithmus",cmdline[0],"unbekannt." sys.exit(1) deltime=15 if len(cmdline)>1: deltime=int(cmdline[1]) wmeth = Toplevel(root) wmeth.title("Animierte Sortieralgorithmen:" + meth) doit(wmeth, meth, deltime) root.after(1000) root.update() wmeth.destroy() root.mainloop() ###################################################################### start() ======================== -- Dr. David J. Ritchie, Sr. djrassoc01@mindspring.com http://home.mindspring.com/~djrassoc01/ From urnerk@qwest.net Mon Feb 25 16:52:40 2002 From: urnerk@qwest.net (Kirby Urner) Date: Mon, 25 Feb 2002 08:52:40 -0800 Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <3C7A5C1A.93A2192@mindspring.com> References: <1014583999.1496.12.camel@robeson> <001701c1bdd0$1087ff80$1664a8c0@mega> Message-ID: <4.2.0.58.20020225085153.00ac8100@pop3.norton.antivirus> Judging purely from the demos, insertion-sort seemed fastest. Kirby From glingl@aon.at Mon Feb 25 17:21:46 2002 From: glingl@aon.at (Gregor Lingl) Date: Mon, 25 Feb 2002 18:21:46 +0100 Subject: [Edu-sig] Analyzing algorithms... References: <1014583999.1496.12.camel@robeson> <001701c1bdd0$1087ff80$1664a8c0@mega> <4.2.0.58.20020225085153.00ac8100@pop3.norton.antivirus> Message-ID: <002c01c1be20$e9803910$1664a8c0@mega> In my opinion it is not feasible to measure or even estimate the runtime- behaviour of those algorithms from the demos. They use different time-constants for the animation: def do_demo(meth,deltime): global root root = Tk() root.title("Animierte Sortieralgorithmen") doit(meth,deltime) root.after(1000) root.update() root.destroy() def demo(): do_demo('bubble',5) do_demo('bubbleclever ',11) do_demo('shaker',15) do_demo('selection ',22) do_demo('insertion ',4) do_demo('shell',25) do_demo('quick',50) do_demo('heap',28) do_demo('merge',22) Moreover most of the time is consumed by displaying the graphics and it is questionable if the time consumed by those canvas.update()-calls is proportional to the time of the not animated sorts. Gregor ----- Original Message ----- From: "Kirby Urner" To: Sent: Monday, February 25, 2002 5:52 PM Subject: Re: [Edu-sig] Analyzing algorithms... > > Judging purely from the demos, insertion-sort seemed fastest. > > Kirby > > > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig > From urnerk@qwest.net Mon Feb 25 18:03:37 2002 From: urnerk@qwest.net (Kirby Urner) Date: Mon, 25 Feb 2002 10:03:37 -0800 Subject: [Edu-sig] Analyzing algorithms... In-Reply-To: <002c01c1be20$e9803910$1664a8c0@mega> References: <1014583999.1496.12.camel@robeson> <001701c1bdd0$1087ff80$1664a8c0@mega> <4.2.0.58.20020225085153.00ac8100@pop3.norton.antivirus> Message-ID: <4.2.0.58.20020225100240.01ae2ea0@pop3.norton.antivirus> At 06:21 PM 2/25/2002 +0100, Gregor Lingl wrote: >In my opinion it is not feasible to >measure or even estimate the runtime- >behaviour of those algorithms from the demos. Yeah, that sounds reasonable. The point of the animations is to give some idea of how they work, not which is ultimately fastest. A caveat to share with students if using them in a classroom setting. Kirby From djrassoc01@mindspring.com Mon Feb 25 23:10:49 2002 From: djrassoc01@mindspring.com (Dr. David J. Ritchie, Sr.) Date: Mon, 25 Feb 2002 17:10:49 -0600 Subject: [Edu-sig] Analyzing algorithms... References: <1014583999.1496.12.camel@robeson> <001701c1bdd0$1087ff80$1664a8c0@mega> <4.2.0.58.20020225085153.00ac8100@pop3.norton.antivirus> <4.2.0.58.20020225100240.01ae2ea0@pop3.norton.antivirus> Message-ID: <3C7AC477.A3087AAD@mindspring.com> In regard to what Kirby Urner wrote: > At 06:21 PM 2/25/2002 +0100, Gregor Lingl wrote: > >In my opinion it is not feasible to > >measure or even estimate the runtime- > >behaviour of those algorithms from the demos. > > Yeah, that sounds reasonable. The point of the > animations is to give some idea of how they work, > not which is ultimately fastest. A caveat to > share with students if using them in a classroom > setting. > Yes. I used it as part of our 50 minute computer club today for seven students in sixth-eighth grades and it provided a good example of different sorting techniques. Thank you very much to those who authored and contributed it. --David -- Dr. David J. Ritchie, Sr. djrassoc01@mindspring.com http://home.mindspring.com/~djrassoc01/ From delza@mac.com Tue Feb 26 17:41:38 2002 From: delza@mac.com (Dethe Elza) Date: Tue, 26 Feb 2002 09:41:38 -0800 Subject: [Edu-sig] OnLisp Message-ID: <15EE88CE-2AE0-11D6-9827-003065CA8E18@mac.com> You can download Paul Graham's out-of-print book On Lisp. I found out about this from an interesting weblog called "Everything Burns" (http://jimfl.tensegrity.net/), which had this to say about it: I esteem OnLisp to be one of the most well-written, compelling books I have encountered on any topic in computing. This is no mean praise considering various works by one Stanford Professor name of Knuth. You don't really have to care much about Lisp or its variants to enjoy this book, though you should, at least, be able to tolerate topics which arise from the peculiarities in Lisp-shaped languages. Familiarity with Lisp will serve a programmer in any language anyway. Sadly, OnLisp is out of print, but you can download it free of charge. You will be missing only the weight of the dense paperback in your hands, the attractive cover, and the few figures sprinkled throughout. http://www.paulgraham.com/onlisptext.html --Dethe -- Dethe Elza (delza@burningtiger.com) Chief Mad Scientist Burning Tiger Technologies (http://www.burningtiger.com) Weblog: http://livingcode.manilasites.com/ From jeff@elkner.net Wed Feb 27 17:25:24 2002 From: jeff@elkner.net (Jeffrey Elkner) Date: 27 Feb 2002 12:25:24 -0500 Subject: [Edu-sig] COUNTER class. In-Reply-To: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> References: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> Message-ID: <1014830745.7303.103.camel@mdeicaza> Hi Kirby, With the help of student Python guru, Lex Berezhny, I've been playing around a bit with the suggestion you sent me. Here is what I get when I attempt to merge the "Element" class you sent me with a "countable thing" class that Lex showed me: class COUNTER: stat_state = {} def __init__(self, value = 0, type): self.value = value if not self.stat_state.has_key(type): self.stat_state[type] = stat_state = {"assign": 0, "compare": 0} self.stat = self.stat_state[type] def __repr__(self): return str(self.value) def __eq__(self, other): self.state["compare"] += 1 return self.value == other.value def __gt__(self, other): self.state["compare"] += 1 return self.value > other.value def __lt__(self, other): self.state["compare"] += 1 return self.value < other.value def __le__(self, other): self.state["compare"] += 1 return self.value <= other.value def __ge__(self, other): self.state["compare"] += 1 return self.value >= other.value The idea is to create a class of things that know how to count together, so that they increment a common counter (so a > b should only count 1 comparison). I couldn't find a way to give this property to assignment. Every time an assignment happens with one of these things, I would like to count it. Is there a way to do that? jeff From urnerk@qwest.net Thu Feb 28 03:47:19 2002 From: urnerk@qwest.net (Kirby Urner) Date: Wed, 27 Feb 2002 19:47:19 -0800 Subject: [Edu-sig] COUNTER class. In-Reply-To: <1014830745.7303.103.camel@mdeicaza> References: <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> <4.2.0.58.20020224133240.00d08300@pop3.norton.antivirus> Message-ID: <4.2.0.58.20020227193920.00cdf520@pop3.norton.antivirus> > >I couldn't find a way to give this property to assignment. Every time an >assignment happens with one of these things, I would like to count it. >Is there a way to do that? > >jeff Trickier I think, because unlike <, > etc., = doesn't trigger some __xxx__ method. But sticking something in a property or explicitly invoking a method could work. If you're willing to do something like: b.assign(a) or b.value = a in place of b = a then we'd have some options. But that might detract from the readibility of your sort algorithms, as there's nothing more natural than plain old =. So maybe we fall back to triggering an assignment counter each time there's an assignment, e.g. pepper the code like: a = b a.assign() # not sure if you count one or both That's not much better than sticking in accumulator variables, but perhaps keeps things clearner in that you're still using the elements to be sorted to keep track of their own manipulations. Kirby