Hi, In a surprise move, our local paper actually accepted one of our invitations to come see what we do in Comp Sci at the secondary level, namely our Python elective, which is mostly for first time programmers. The resulting article isn't bad, given that the kids were certain the reporter didn't understand a word they told her... ;) links to the web and printable version are here: web - http://www.jg.net/article/20101206/LOCAL04/312069949 printable - http://www.jg.net/apps/pbcs.dll/article?AID=/20101206/LOCAL04/312069949&template=printart Cheers, Vern -- Vern Ceder vceder@gmail.com, vceder@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
On Mon, Dec 6, 2010 at 5:44 AM, Vern Ceder <vceder@gmail.com> wrote:
Hi, In a surprise move, our local paper actually accepted one of our invitations to come see what we do in Comp Sci at the secondary level, namely our Python elective, which is mostly for first time programmers. The resulting article isn't bad, given that the kids were certain the reporter didn't understand a word they told her... ;) links to the web and printable version are here: web - http://www.jg.net/article/20101206/LOCAL04/312069949 printable - http://www.jg.net/apps/pbcs.dll/article?AID=/20101206/LOCAL04/312069949&template=printart Cheers, Vern -- Vern Ceder vceder@gmail.com, vceder@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
Hi Vern -- That's a cool little article. I wrote this Python program to provide an applause track for ya (I think I spelled "shriek" wrong): == forvern.py == import threading from random import choice, randint import time noises = ["Bravo!\n","Clap Clap\n","Yay!\n","whistle\n","shreek\n"] class AudiencePerson( threading.Thread): def __init__(self, an, interval): self.applause_noise = an self.interval = interval super(AudiencePerson, self).__init__() def run(self): for i in range(5): print self.getName() + ": " + self.applause_noise time.sleep(self.interval) def testme(): for i in range(10): AudiencePerson(choice(noises), randint(0,5)/10.).start() return if __name__ == "__main__": testme() === Now if I could just turn that into a COM object (seriously, I'm trying to figure out how to call movingballs2.py, a Vpython script, from Visual FoxPro). I also passed on news of said article to an English teacher friend... Excerpt from outbox: --- A guy named Jon Birdsong with startup OpenStudy (OpenStudy.com) was in contact through Python list and I clued him re Martian Math. My hit counter jumped from like 1000 to 2000 though I don't know for sure there's any correlation. I referred him to the article on Vern Ceder. Excerpt (fixed typos): """ Here's a good one: http://www.jg.net/article/20101206/LOCAL04/312069949 Vern is our "watcher" (keying off Giles of Buffy VS), keeps a lookout for talent wanted to have posters at a Pycon. I mention his role in my briefing to GIS in Action / 2009: http://www.4dsolutions.net/presentations/gis_2009_workshop.pdf (EduPython track slide, lots more on PN) """ Letter exchange on Wikieducator list (how our correspondence began): http://groups.google.com/group/wikieducator/msg/3601e5b274b6190a?hl=en --- All in a day's work, Kirby
Now if I could just turn that into a COM object (seriously, I'm trying to figure out how to call movingballs2.py, a Vpython script, from Visual FoxPro).
OK, I turned it into a COM object, pretty mickey mouse, yet instructive (at least to me): VFP = Visual FoxPro and in the middle you'll see how I'm in the interactive shell of that language, and creating this Python object. Even though control returns to the host language, the threads spawn and do their business, taking their time to fill a randomly named text file in some pre-specified directory. My thanks to Mark Hammond the one and only for swinging by on comp.lang.python -- more acknowledgment in my blog: http://mybizmo.blogspot.com/2010/12/office-work.html Here's the COM version (pycomsupport dependency not included for brevity) import threading from random import choice, randint import pycomsupport import os import time applause = ["Bravo!\n","Clap Clap\n","Yay!\n","whistle\n","shreek\n"] laugh = ["chuckle\n", "guffaw\n", "hoot\n", "howl\n", "ROFL\n"] boo = ["Boo!\n", "Nada mas!\n", "hissss\n"] class MPSS_Audience ( object ): _public_methods_ = [ 'applause_track', 'laugh_track', 'boo_track' ] _reg_progid_ = "LoadOpt.Feedback" # Use pythoncom.CreateGuid()" to make a new clsid _reg_clsid_ = '{BFE032DC-0F31-47CA-A714-7D6AADA41F5C}' def __init__(self, ident = None): self.logger = ident fp = os.path.normpath("C:\Users\Kirby\Documents\Visual FoxPro Projects\mpss") fn = pycomsupport.randomstring(8)+".txt" self.output = os.path.join(fp, fn) def _noise_threads(self, noise_type): hnd = open(self.output, 'w') for i in range(10): AudiencePerson(hnd, choice(noise_type), randint(0,5)).start() def applause_track(self): self._noise_threads(applause) def laugh_track(self): self._noise_threads(laugh) def boo_track(self): self._noise_threads(boo) class AudiencePerson( threading.Thread ): def __init__(self, output, an, interval): self.output = output self.audience_noise = an self.interval = interval super(AudiencePerson, self).__init__() def run(self): for i in range(5): self.output.write(self.getName() + ": " + self.audience_noise) time.sleep(self.interval) def testme(): loObj = MPSS_Audience(1) loObj.laugh_track() if __name__ == "__main__": print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(MPSS_Audience) testme() On the VFP side: loCircus = CREATEOBJECT("Loadopt.Feedback", "some param") loCircus.applause_track() control returns immediately, even though the text file takes quite awhile to fill, thanks to the several second delays between thread writes. The final file: Thread-1: whistle Thread-2: shreek Thread-3: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-8: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-10: Clap Clap Thread-2: shreek Thread-8: Clap Clap Thread-2: shreek Thread-8: Clap Clap Thread-2: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-8: Clap Clap Thread-1: whistle Thread-2: shreek Thread-3: shreek Thread-8: Clap Clap Thread-10: Clap Clap Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-1: whistle Thread-3: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-10: Clap Clap Thread-1: whistle Thread-4: whistle Thread-3: shreek Thread-5: Yay! Thread-6: whistle Thread-10: Clap Clap Thread-1: whistle Thread-3: shreek Thread-10: Clap Clap Kirby
Thanks for both versions, Kirby! I'll take the applause wherever/however I can get it. ;) I'm not into COM/Windows much, but the basic example is a neat way to illustrate threading... I'll have to remember to steal it, maybe for the classes I teach to our 8th graders. ;) Speaking of 8th graders, these days I'm also teaching online Python courses for middle school kids through Northwestern's Gifted Learrning Links program - an intro to Python using Hello World! and (starting in January) an intermediate Python class, which will do more with OOP concepts and GUI's. The link is here (the intermediate course isn't up yet, but should be soon) - http://www.ctd.northwestern.edu/gll/courses/enrichment/winter2011/#Technolog... Cheers, Vern On Sat, Dec 11, 2010 at 12:12 AM, kirby urner <kirby.urner@gmail.com> wrote:
Now if I could just turn that into a COM object (seriously, I'm trying to figure out how to call movingballs2.py, a Vpython script, from Visual FoxPro).
OK, I turned it into a COM object, pretty mickey mouse, yet instructive (at least to me):
VFP = Visual FoxPro and in the middle you'll see how I'm in the interactive shell of that language, and creating this Python object.
Even though control returns to the host language, the threads spawn and do their business, taking their time to fill a randomly named text file in some pre-specified directory.
My thanks to Mark Hammond the one and only for swinging by on comp.lang.python -- more acknowledgment in my blog:
http://mybizmo.blogspot.com/2010/12/office-work.html
Here's the COM version (pycomsupport dependency not included for brevity)
import threading from random import choice, randint import pycomsupport import os import time
applause = ["Bravo!\n","Clap Clap\n","Yay!\n","whistle\n","shreek\n"] laugh = ["chuckle\n", "guffaw\n", "hoot\n", "howl\n", "ROFL\n"] boo = ["Boo!\n", "Nada mas!\n", "hissss\n"]
class MPSS_Audience ( object ):
_public_methods_ = [ 'applause_track', 'laugh_track', 'boo_track' ] _reg_progid_ = "LoadOpt.Feedback"
# Use pythoncom.CreateGuid()" to make a new clsid _reg_clsid_ = '{BFE032DC-0F31-47CA-A714-7D6AADA41F5C}'
def __init__(self, ident = None): self.logger = ident fp = os.path.normpath("C:\Users\Kirby\Documents\Visual FoxPro Projects\mpss") fn = pycomsupport.randomstring(8)+".txt" self.output = os.path.join(fp, fn)
def _noise_threads(self, noise_type): hnd = open(self.output, 'w')
for i in range(10): AudiencePerson(hnd, choice(noise_type), randint(0,5)).start()
def applause_track(self): self._noise_threads(applause)
def laugh_track(self): self._noise_threads(laugh)
def boo_track(self): self._noise_threads(boo)
class AudiencePerson( threading.Thread ):
def __init__(self, output, an, interval): self.output = output self.audience_noise = an
self.interval = interval super(AudiencePerson, self).__init__()
def run(self): for i in range(5): self.output.write(self.getName() + ": " + self.audience_noise)
time.sleep(self.interval)
def testme(): loObj = MPSS_Audience(1) loObj.laugh_track()
if __name__ == "__main__": print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(MPSS_Audience) testme()
On the VFP side:
loCircus = CREATEOBJECT("Loadopt.Feedback", "some param") loCircus.applause_track()
control returns immediately, even though the text file takes quite awhile to fill, thanks to the several second delays between thread writes. The final file:
Thread-1: whistle Thread-2: shreek Thread-3: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-7: Yay! Thread-8: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-9: Clap Clap Thread-10: Clap Clap Thread-2: shreek Thread-8: Clap Clap Thread-2: shreek Thread-8: Clap Clap Thread-2: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-8: Clap Clap Thread-1: whistle Thread-2: shreek Thread-3: shreek Thread-8: Clap Clap Thread-10: Clap Clap Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-1: whistle Thread-3: shreek Thread-4: whistle Thread-5: Yay! Thread-6: whistle Thread-10: Clap Clap Thread-1: whistle Thread-4: whistle Thread-3: shreek Thread-5: Yay! Thread-6: whistle Thread-10: Clap Clap Thread-1: whistle Thread-3: shreek Thread-10: Clap Clap
Kirby
-- Vern Ceder vceder@gmail.com, vceder@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
On Sun, Dec 12, 2010 at 11:24 AM, Vern Ceder <vceder@gmail.com> wrote:
Thanks for both versions, Kirby! I'll take the applause wherever/however I can get it. ;)
That's cool. You've been a good Giles, a role I can also relate too.
I'm not into COM/Windows much, but the basic example is a neat way to illustrate threading... I'll have to remember to steal it, maybe for the classes I teach to our 8th graders. ;)
Yeah, me either until recently. Good example of a host environment wrapping an alien "egg" (in this case a Python COM object) and continuing to run its own process, even while triggering running code in this other language. I'm beholden to the Medusa metaphor of asynchronous event handling. A thread is a lot like a Python generator in that it time shares through next iterations. Twisted is what became of her, outside of Zope.
Speaking of 8th graders, these days I'm also teaching online Python courses for middle school kids through Northwestern's Gifted Learrning Links program - an intro to Python using Hello World! and (starting in January) an intermediate Python class, which will do more with OOP concepts and GUI's. The link is here (the intermediate course isn't up yet, but should be soon) - http://www.ctd.northwestern.edu/gll/courses/enrichment/winter2011/#Technolog...
This is all good. I've been back in touch with the VPython principal, Bruce Sherwood, to compare notes. He used to get guff from Arthur on this list, yet they found a symbiotic pattern around Numpy. For those more recently joining us: Arthur was our friend in the NYC financial sector who jumped onto Python + VPython in a big way, to develop his Pygeo projective geometry toolkit. I'd hoped to see him at a GWU / Pycon, one of Steve Holden's events, but that's the year my wife needed me home pronto (I was already in DC for a Bucky Fuller symposium, also at GWU). As it was, we had a good dinner with David Lansky and his kids, in New York City itself. Some kind of ethnic pancake place, upper east side. Anyway, just reminiscing about some of our players. The Python community is pretty stellar, although I'm also blown away by Perl's. I just haven't met that many Ruby people yet. I should probably go to some Rubicons, if that's what they're called. One of my favorite Java programmers is Gerald de Jong, who pretty much invented the field of Elastic Interval Geometry. Here's one of his Youtubes. http://www.youtube.com/watch?v=-6I3utbJ1M8 See springie.com by Tim Tyler for another excellent example of an EIG application. These days Gerald is the solo programmer on a multi-user game called Tetragotchi. He's amazing. http://www.youtube.com/watch?v=xis6QxneccM (someone filming beta tetragotchi) Kirby PS: I need to stick a Queue object on the head of my jellyfish (Medusa COM object). As FoxPro calls in, yelling "route me a truck", I'll queue the request, not unlike an httprequest. Indeed, some might ask "why not use XML-RPC"? Well, you'd still have the same dynamic of needing to return a "job ticket" right away, then have the caller come back for the dry cleaning another time. So asynchronous thinking would be involved.
Cheers, Vern
Hello Kirby et al, OK, you guys should be very proud of me. I've been dabbling on the outskirts of your fine python community until recently. I entered your world via a back door of sorts. I was looking for a new curriculum for my intro CompSci students and found Gary Litvin's new text "Mathematics for the Digital Age" which details a course in Discrete Mathematics with an emphasis on Pythonic Math. I was using SAGE with these students all year until now. Unfortunately, I've met with a lot of lag and downtime using the various online SAGE servers recently. So, I finally broke down and installed a FTP/SFTP server just for this class using Ubuntu Linux and I installed Python and IDLE. We've been writing python scripts for 2 weeks now and we're not looking back! Enjoy, A. Jorge Garcia Applied Math & CS Baldwin SHS & Nassau CC http://shadowfaxrant.blogspot.com http://www.youtube.com/calcpage2009 Sent from my iPod On Dec 13, 2010, at 5:36 PM, kirby urner <kirby.urner@gmail.com> wrote:
On Sun, Dec 12, 2010 at 11:24 AM, Vern Ceder <vceder@gmail.com> wrote: Thanks for both versions, Kirby! I'll take the applause wherever/ however I can get it. ;)
That's cool. You've been a good Giles, a role I can also relate too.
I'm not into COM/Windows much, but the basic example is a neat way to illustrate threading... I'll have to remember to steal it, maybe for the classes I teach to our 8th graders. ;)
Yeah, me either until recently. Good example of a host environment wrapping an alien "egg" (in this case a Python COM object) and continuing to run its own process, even while triggering running code in this other language.
I'm beholden to the Medusa metaphor of asynchronous event handling. A thread is a lot like a Python generator in that it time shares through next iterations. Twisted is what became of her, outside of Zope.
Speaking of 8th graders, these days I'm also teaching online Python courses for middle school kids through Northwestern's Gifted Learrning Links program - an intro to Python using Hello World! and (starting in January) an intermediate Python class, which will do more with OOP concepts and GUI's. The link is here (the intermediate course isn't up yet, but should be soon) - http://www.ctd.northwestern.edu/gll/courses/enrichment/winter2011/#Technolog...
This is all good. I've been back in touch with the VPython principal, Bruce Sherwood, to compare notes. He used to get guff from Arthur on this list, yet they found a symbiotic pattern around Numpy.
For those more recently joining us: Arthur was our friend in the NYC financial sector who jumped onto Python + VPython in a big way, to develop his Pygeo projective geometry toolkit.
I'd hoped to see him at a GWU / Pycon, one of Steve Holden's events, but that's the year my wife needed me home pronto (I was already in DC for a Bucky Fuller symposium, also at GWU).
As it was, we had a good dinner with David Lansky and his kids, in New York City itself. Some kind of ethnic pancake place, upper east side.
Anyway, just reminiscing about some of our players. The Python community is pretty stellar, although I'm also blown away by Perl's.
I just haven't met that many Ruby people yet. I should probably go to some Rubicons, if that's what they're called.
One of my favorite Java programmers is Gerald de Jong, who pretty much invented the field of Elastic Interval Geometry. Here's one of his Youtubes.
http://www.youtube.com/watch?v=-6I3utbJ1M8
See springie.com by Tim Tyler for another excellent example of an EIG application.
These days Gerald is the solo programmer on a multi-user game called Tetragotchi. He's amazing.
http://www.youtube.com/watch?v=xis6QxneccM (someone filming beta tetragotchi)
Kirby
PS: I need to stick a Queue object on the head of my jellyfish (Medusa COM object). As FoxPro calls in, yelling "route me a truck", I'll queue the request, not unlike an httprequest. Indeed, some might ask "why not use XML-RPC"? Well, you'd still have the same dynamic of needing to return a "job ticket" right away, then have the caller come back for the dry cleaning another time. So asynchronous thinking would be involved.
Cheers, Vern
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
Darned right, we're proud of you! Python and Linux - way to go! ;) Cheers, Vern On Mon, Dec 13, 2010 at 7:08 PM, Calcpage <calcpage@aol.com> wrote:
Hello Kirby et al,
OK, you guys should be very proud of me. I've been dabbling on the outskirts of your fine python community until recently. I entered your world via a back door of sorts. I was looking for a new curriculum for my intro CompSci students and found Gary Litvin's new text "Mathematics for the Digital Age" which details a course in Discrete Mathematics with an emphasis on Pythonic Math. I was using SAGE with these students all year until now. Unfortunately, I've met with a lot of lag and downtime using the various online SAGE servers recently. So, I finally broke down and installed a FTP/SFTP server just for this class using Ubuntu Linux and I installed Python and IDLE. We've been writing python scripts for 2 weeks now and we're not looking back!
Enjoy, A. Jorge Garcia Applied Math & CS Baldwin SHS & Nassau CC http://shadowfaxrant.blogspot.com http://www.youtube.com/calcpage2009 Sent from my iPod
On Dec 13, 2010, at 5:36 PM, kirby urner <kirby.urner@gmail.com> wrote:
On Sun, Dec 12, 2010 at 11:24 AM, Vern Ceder < <vceder@gmail.com> vceder@gmail.com> wrote:
Thanks for both versions, Kirby! I'll take the applause wherever/however I can get it. ;)
That's cool. You've been a good Giles, a role I can also relate too.
I'm not into COM/Windows much, but the basic example is a neat way to illustrate threading... I'll have to remember to steal it, maybe for the classes I teach to our 8th graders. ;)
Yeah, me either until recently. Good example of a host environment wrapping an alien "egg" (in this case a Python COM object) and continuing to run its own process, even while triggering running code in this other language.
I'm beholden to the Medusa metaphor of asynchronous event handling. A thread is a lot like a Python generator in that it time shares through next iterations. Twisted is what became of her, outside of Zope.
Speaking of 8th graders, these days I'm also teaching online Python courses for middle school kids through Northwestern's Gifted Learrning Links program - an intro to Python using Hello World! and (starting in January) an intermediate Python class, which will do more with OOP concepts and GUI's. The link is here (the intermediate course isn't up yet, but should be soon) - <http://www.ctd.northwestern.edu/gll/courses/enrichment/winter2011/#Technology> http://www.ctd.northwestern.edu/gll/courses/enrichment/winter2011/#Technolog...
This is all good. I've been back in touch with the VPython principal, Bruce Sherwood, to compare notes. He used to get guff from Arthur on this list, yet they found a symbiotic pattern around Numpy.
For those more recently joining us: Arthur was our friend in the NYC financial sector who jumped onto Python + VPython in a big way, to develop his Pygeo projective geometry toolkit.
I'd hoped to see him at a GWU / Pycon, one of Steve Holden's events, but that's the year my wife needed me home pronto (I was already in DC for a Bucky Fuller symposium, also at GWU).
As it was, we had a good dinner with David Lansky and his kids, in New York City itself. Some kind of ethnic pancake place, upper east side.
Anyway, just reminiscing about some of our players. The Python community is pretty stellar, although I'm also blown away by Perl's.
I just haven't met that many Ruby people yet. I should probably go to some Rubicons, if that's what they're called.
One of my favorite Java programmers is Gerald de Jong, who pretty much invented the field of Elastic Interval Geometry. Here's one of his Youtubes.
<http://www.youtube.com/watch?v=-6I3utbJ1M8> http://www.youtube.com/watch?v=-6I3utbJ1M8
See <http://springie.com>springie.com by Tim Tyler for another excellent example of an EIG application.
These days Gerald is the solo programmer on a multi-user game called Tetragotchi. He's amazing.
<http://www.youtube.com/watch?v=xis6QxneccM> http://www.youtube.com/watch?v=xis6QxneccM (someone filming beta tetragotchi)
Kirby
PS: I need to stick a Queue object on the head of my jellyfish (Medusa COM object). As FoxPro calls in, yelling "route me a truck", I'll queue the request, not unlike an httprequest. Indeed, some might ask "why not use XML-RPC"? Well, you'd still have the same dynamic of needing to return a "job ticket" right away, then have the caller come back for the dry cleaning another time. So asynchronous thinking would be involved.
Cheers, Vern
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
-- Vern Ceder vceder@gmail.com, vceder@dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
participants (3)
-
Calcpage
-
kirby urner
-
Vern Ceder