From echerlin at gmail.com Fri Mar 4 06:05:35 2011 From: echerlin at gmail.com (Edward Cherlin) Date: Fri, 4 Mar 2011 00:05:35 -0500 Subject: [Edu-sig] Mosaics using Python... In-Reply-To: References: Message-ID: Your generalized Fibonacci sequences and generalized Pascal's Triangles are linear combinations of the standard sequences and triangles with shifts. m,n,m+n,m+2n, 2m+3n... is the sum of the sequences m,0,m,m,2m,... 0,n,n,2n,3n,... and similarly, the coefficients of x, y, and z in this triangle are all Pascal numbers. x, y, z x, x+y, y+z, z x, 2x+y, x+2y+z, y+2z, z x, 3x+y, 3x+3y+z, x+3y+3z, y+3z, z On Fri, Feb 4, 2011 at 15:10, kirby urner wrote: > """ > Mosaics using Python generators... > by K. Urner > 4dsolutions.net > based on a thread on mathfuture: > http://groups.google.com/group/mathfuture/msg/9d098696c2ea7426?hl=en > Just as the Fibonacci sequence generator might be "seeded" by any > two integers to start off, so might Pascal's Triangle be seeded with > any beginning row. > When these sequences are formed into tabular or other areal displays, > such that information may be gleaned from rows and columns, these > formats may be called "mosaics" in some of the literature. > """ > def fibonacci( a=0, b=1): > ?? ?""" > ?? ?Generator for a Fibonacci sequence starting from any two integers > ?? ?See: ?Online Encyclopedia of Integer Sequences > ?? ?http://oeis.org/A000045 > > ?? ?>>> gen = fibonacci() > ?? ?>>> [next(gen) for i in range(11)] > ?? ?[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] > ?? ?>>> gen = fibonacci(-1, 2) > ?? ?>>> [next(gen) for i in range(11)] > ?? ?[-1, 2, 1, 3, 4, 7, 11, 18, 29, 47, 76] > ?? ?""" > ?? ?while True: > ?? ? ? ?yield a > ?? ? ? ?b, a = a + b, b > > def pascal( therow = [1]): > ?? ?""" > ?? ?Generator for Pascal's Triangle starting from any top row > ?? ?Enter list for top row > ?? ?See: ?Number Mosaics by?Adi R. Kanga? (pg. 29, Fig 20) > ?? ?http://bit.ly/gDmmAo > > ?? ?>>> gen = pascal([15, 20, 6]) > ?? ?>>> next(gen) > ?? ?[15, 20, 6] > ?? ?>>> next(gen) > ?? ?[15, 35, 26, 6] > ?? ?>>> next(gen) > ?? ?[15, 50, 61, 32, 6] > ?? ?>>> next(gen) > ?? ?[15, 65, 111, 93, 38, 6] > ?? ?>>> next(gen) > ?? ?[15, 80, 176, 204, 131, 44, 6] > ?? ?>>> next(gen) > ?? ?[15, 95, 256, 380, 335, 175, 50, 6] > ?? ?""" > ?? ?while True: > ?? ? ? ?yield therow > ?? ? ? ?therow = [ i + j for i, j in zip(therow + [0], [0] + therow) ] > > def _test(): > ?? ?import doctest > ?? ?doctest.testmod() > if __name__ == "__main__": > ?? ? ? ?_test() > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From vceder at gmail.com Mon Mar 7 16:16:11 2011 From: vceder at gmail.com (Vern Ceder) Date: Mon, 7 Mar 2011 10:16:11 -0500 Subject: [Edu-sig] Edu-Sig at PyCon Message-ID: Hi everyone, This is a last note - is anyone else interested in an Edu-Sig open space at PyCon? I've created a wiki page for it at http://us.pycon.org/2011/openspaces/EduSig/. I've also started an Edu-Sig BoF thread on convore (all the cool kids are using it) at https://convore.com/pycon-2011/python-in-education-bof/ And if there isn't any interest, that's OK, too. :) Cheers, Vern -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From calcpage at aol.com Tue Mar 8 03:34:48 2011 From: calcpage at aol.com (A. Jorge Garcia) Date: Mon, 07 Mar 2011 21:34:48 -0500 Subject: [Edu-sig] NEW: Blogs, Videos and Donorschoose! In-Reply-To: <8CD948035BEAA47-1744-230AB@webmail-d146.sysops.aol.com> References: <8CD948035BEAA47-1744-230AB@webmail-d146.sysops.aol.com> Message-ID: <8CDAB50873E1B8D-23D8-5EBE@webmail-d138.sysops.aol.com> Please enjoy my latest blogs! http://shadowfaxrant.blogspot.com/2011/03/great-computer-science-vs-computing.html http://shadowfaxrant.blogspot.com/2011/03/birthdays-and-pheasants.html http://shadowfaxrant.blogspot.com/2011/02/nova-nova-everywhere.html http://shadowfaxrant.blogspot.com/2011/02/my-21st-century-math-classroom.html Here's some new Algebra II Trig and preCalculus related screen-casts (Conics and Polar Mode)! http://www.youtube.com/calcpage2009 HTH, A. Jorge Garcia Applied Math and CompSci http://shadowfaxrant.blogspot.com http://www.youtube.com/calcpage2009 From spiff11111 at yahoo.com Tue Mar 8 17:23:16 2011 From: spiff11111 at yahoo.com (ray spiering) Date: Tue, 8 Mar 2011 08:23:16 -0800 (PST) Subject: [Edu-sig] Which shell to use Message-ID: <914747.39923.qm@web31604.mail.mud.yahoo.com> Good morning, ? I am trying to use/teach Python 3.0 in a classroom environment. Should I use the shell that was part of the download, or one of the improved shells that I read about on the web? ? Thanks, ?? Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Tue Mar 8 18:32:52 2011 From: kirby.urner at gmail.com (kirby urner) Date: Tue, 8 Mar 2011 09:32:52 -0800 Subject: [Edu-sig] Which shell to use In-Reply-To: <914747.39923.qm@web31604.mail.mud.yahoo.com> References: <914747.39923.qm@web31604.mail.mud.yahoo.com> Message-ID: Good question. Depends *a lot* on the curriculum. If students are just being introduced to the idea of an REPL (read evaluate print loop) then showing off more than one IDE at the outset might prove enlightening. Show & Tell: Python with vim in Linux shell. Show & Tell: Python with IDLE with Akbar font (one of my faves) http://www.flickr.com/photos/17157315 at N00/5457528415/in/set-72157625646071793/ Show & Tell: Python with PyDev module (still being improved) in Eclipse. The last one is what I end up using with students these days, but I've mostly used IDLE in other classrooms. Kirby On Tue, Mar 8, 2011 at 8:23 AM, ray spiering wrote: > Good morning, > > I am trying to use/teach Python 3.0 in a classroom environment. > Should I use the shell that was part of the download, or one of the > improved shells that I read about on the web? > > Thanks, > Joe > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Tue Mar 8 19:59:30 2011 From: kirby.urner at gmail.com (kirby urner) Date: Tue, 8 Mar 2011 10:59:30 -0800 Subject: [Edu-sig] UnitTest? In-Reply-To: <4D6AFC46.7060106@ece.arizona.edu> References: <1DECD34B57C2C44A8F3374D034E6735A03133C6F79D9@amp.gsc.edu> <4D69385A.2050906@ece.arizona.edu> <201102261825.p1QIPKNu005905@theraft.openend.se> <4D6AFC46.7060106@ece.arizona.edu> Message-ID: Per the Steve Holden curriculum, which I'm currently teaching, we start with doctest and get?students familiar with the whole idea of test driven development (TDD), which is presented as an aspect of "agile programming". The beginner level leaves it at that, with the intermediate course starting in on unittest.[0] The downside of doctest is it clutters docstrings, meant to provide help to a user, with lots of testing noise. One could argue this is "documentation by example" but it doesn't fit the template of standard library or 3rd party docstrings. Also, unittest lets you set up dummy files and directories, other stub resources (so-called fixtures) before moving on to the actual test. And you can separated the test suites from the actual module being tested, reserving the former for the dev platform, the latter for distribution. The thing about CS is it's highly vocational so you wouldn't just Show & Tell about this stuff, to develop a reading knowledge (like of Latin [1]) and then move on to other topics, e.g. tcp/ip. That'd be more like an "engineering for poets" class. Those doing a lot of hands-on unittest in Standard University are implicitly committing to x hours per week doing programming, whereas those studying through OERs etc. might just wanna dabble to get a sense of it. Like going to a user group talk, not on the hook to turn in assignments on unittest in particular.[3] The Holden course is of the standard variety, meaning it's all about hands-on and assumes a pretty high level of commitment, in terms of wanting to learn the ins and outs and have them stick. It's not just "exposure" like the poets might get. Kirby [0] http://www.oreillyschool.com/courses/python1/ (Steve being interviewed by Trish during the recently concluded annual staff meeting) [1] I've been telling students that Ruby, Python and Perl are like Spanish, French and Italian (though I don't say what maps to what) in terms of being of the same family (Latin aka Romance languages). As Rob remarked (a Ruby guy), that's an analogy Larry Wall should appreciate. [2] OERs = open courseware, like you can get from MIT, Yale etc. On Sun, Feb 27, 2011 at 5:37 PM, David MacQuigg wrote: > > As usual, Pilgrim does an excellent job of explaining his topic. ?I haven't looked at unittest for years, but Chapter 9 in his new book explains it well. > > That said, I still prefer doctest over unittest. > 1) doctests can be introduced on day one, without much explanation. ?Pilgrim waits until Chapter 9 to introduce the unittest module, and then the presentation depends on students already knowing how to define classes. ?At that point, it is much harder to get students to change their habits, and start writing tests for even the simplest functions. ?Even worse, students who stop short of learning OOP, and that includes most who are not intending to be programmers, those students will never appreciate the value of including tests as an integral part of writing a program. > 2) doctests look just like what students will enter in an interactive session, while testing some function they have just written. ?Cut-and-paste a successful test from the interpreter to the editor window, and you are done. > 3) doctests serve two functions - documentation and testing. ?Start with a simple well-written doctest to make the purpose of a function crystal clear. ?Then add numerous unit tests, one at a time as you think of them, placing them in a separate test function to a avoid a conflict between clarity and completeness. ?Refine your doctests to make the explanation even more clear, but don't throw away your old doctests. ?Just move them to the unit test function. > 4) The explanatory doctests are what motivate students to write any tests at all. ?Without this, writing tests gets put off to the end, or never done. > > Google [python doctest] for lots of interesting discussion. ?Two very helpful links: > http://blog.tplus1.com/index.php/2008/07/14/python-doctests-seem-underappreciated/ > http://stackoverflow.com/questions/361675/python-doctest-vs-unittest > > See pykata.org for examples that make extensive use of doctests for both explanation and unit testing. > > > On 2/26/11 11:25 AM, Laura Creighton wrote: >> >> In a message of Sat, 26 Feb 2011 10:28:58 MST, David MacQuigg writes: >>> >>> In my opinion, the unittest framework is way too cumbersome for an >>> introductory course. ?Doctests are simple and self-explanatory. >>> Students should get in the habit of writing a doctest for every function >>> they write, even before the function itself is written. >> >> I think this is a reason to use py.test or nose rather than unittest, >> but not a reason to use doctest. ?I'm very fond of Mark Pilgrim's Unit >> testing chapter in Dive into Python >> http://diveintopython.org/unit_testing/index.html ? (2.x) >> http://diveintopython3.org/unit-testing.html ? ? ? ?(3.x) >> >> which is easy to adapt to a less verbose testing framework. >> >> Laura >> >> >> > > -- > ************************************************************ ? ? * > * David MacQuigg, PhD ? ?email: macquigg at ece.arizona.edu ? * ?* > * Research Associate ? ? ? ? ? ? ? ?phone: USA 520-721-4583 ? * ?* ?* > * ECE Department, University of Arizona ? ? ? ? ? ? ? ? ? ? ? * ?* ?* > * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 9320 East Mikelyn Lane ? ? ? * * * > *http://purl.net/macquigg ? ? ? ? Tucson, Arizona 85710 ? ? ? ? ?* > ************************************************************ ? ? * > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig From vceder at gmail.com Tue Mar 8 21:52:55 2011 From: vceder at gmail.com (Vern Ceder) Date: Tue, 8 Mar 2011 15:52:55 -0500 Subject: [Edu-sig] PyCon - Dinner and a BoF Message-ID: Hi everyone, I'm going ahead on the assumption at least a few of us will be getting dinner together around 6-6:30 Friday evening and then moving to an open space room after that. How does that sound? Cheers, Vern -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From kirby.urner at gmail.com Thu Mar 10 22:50:44 2011 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 10 Mar 2011 13:50:44 -0800 Subject: [Edu-sig] Which shell to use In-Reply-To: <4D781214.7080505@aon.at> References: <914747.39923.qm@web31604.mail.mud.yahoo.com> <4D781214.7080505@aon.at> Message-ID: On Wed, Mar 9, 2011 at 3:49 PM, Gregor Lingl schrieb: > > Some might prefer a monospaced font like the beautiful "Liberation Mono" > (GNU General Public License) for instance. Using a non monospace font can be > irritating sometimes concerning the indentation. > > I should check that out. Fonts that include big swatches of Unicode (such as Kanji) should be fun as well. Note that Akbar and other non-monospace aren't that bad for left-aligned languages such as Python, FORTRAN etc., as the space characters share the same width, so the block indentations appear as rigidly vertical as New Courier's. > Anyway IDLE is a very good choice for beginners, because it's small (and > thus not distracting) but has everything you need during the first year of > learning how to program. (In my experience it's disadvantageous to use an > editor or an IDE that demands a substantial part of the learning energy and > efforts of the students.) > It's also open source in Tkinter so you can scroll through quickly and get an idea of what GUI-based Python is all about. It's pretty easy to get productive in a hurry with Tk bindings -- which is the chief weakness of IDLE: it makes for a crazy-bad Tk development environment, which is what one might be inspired to do, having used IDLE. That's when one starts learning how to boot Python from a command line. If you're not used to a command line, because you're an eye candy junky, on either MacOS or Windows, then here's a golden opportunity to learn on. Then, after learning to go chdir, mkdir, rmdir and whatever, jump into Python's os and shutils and accomplish the same things -- good reinforcement. Learning to love a command line is a core goal of "beginner mind" trainings. Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Fri Mar 11 00:38:54 2011 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 10 Mar 2011 15:38:54 -0800 Subject: [Edu-sig] another IDE option Message-ID: For those already using Visual Studio: http://pytools.codeplex.com/ Kirby not @ Pycon === roland garros to comp-lang-pyth. show details 9:49 PM (17 hours ago) Hi folks, A couple of Python & OSS enthusiasts at msft have produced an add-in for Visual Studio that enables intellisense, browsing, debugging, profiling for CPython and IronPython, along with support for MPI clusters and IPython integration. Would love to hear your feedback! http://pytools.codeplex.com Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/ From kurner at oreillyschool.com Fri Mar 11 00:43:21 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Thu, 10 Mar 2011 15:43:21 -0800 Subject: [Edu-sig] multiplying permutations Message-ID: """ Source code for math-teach post by Kirby Urner / OST (c) GNU Public License, 2011 """ import string, random charset = list(string.ascii_lowercase + " ") def make_perm( ): "make some random permutation object mapping " ",a-z into itself" target = charset[:] # copy all random.shuffle(target) # in place reordering return Pobject(dict( zip(charset, target))) class Pobject: """ permutation objects are instantiated with a dict. they may be multiplied and/or inverted """ def __init__(self, perm): self.perm = perm def encrypt(self, plaintext): e = '' for char in plaintext: e += self.perm[char] return e def decrypt(self, ciphertext): e = '' inv = ~self # invert the permutation return inv.encrypt(ciphertext) def __invert__(self): invdict = {} for char in self.perm: invdict[self.perm[char]] = char return Pobject(invdict) def __mul__(self, other): output = {} for char in self.perm: output[char] = other.perm[self.perm[char]] return Pobject(output) def __repr__(self, abbrev = False): return str(sorted(self.perm.items(), key=lambda t: t[0])) From kirby.urner at gmail.com Fri Mar 11 08:50:09 2011 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 10 Mar 2011 23:50:09 -0800 Subject: [Edu-sig] multiplying permutations In-Reply-To: References: Message-ID: Here's some verbiage on math-teach giving some context for the just-posted source code: http://mathforum.org/kb/message.jspa?messageID=7403815&tstart=0 There's a perennial thread on some math teaching groups as to whether multiplication should be conveyed as "repeated addition", which often seems the sensible approach, but always? In going to other meanings of multiplication, with a family resemblance to rational number multiplication (e.g. existence of inverse such that p * ~p = 1), we venture more into abstract algebra territory. This is where Python shines, as one of those language making operator overloading a snap. Write a class, define __mul__ to suit. Kirby On Thu, Mar 10, 2011 at 3:43 PM, Kirby Urner wrote: > """ > Source code for math-teach post > by Kirby Urner / OST > (c) GNU Public License, 2011 > """ From ufkapano at gmail.com Fri Mar 11 09:34:57 2011 From: ufkapano at gmail.com (Andrzej Kapanowski) Date: Fri, 11 Mar 2011 09:34:57 +0100 Subject: [Edu-sig] multiplying permutations In-Reply-To: References: Message-ID: Hello! Here is a useful class to handle permutations. ----------------------------------------------------------------- class Perm: def __init__(self, size, cycle=None): self.size = size self.data = range(size) if cycle: n = len(cycle) for i in range(n): self.data[cycle[i]] = cycle[(i+1) % n] def __str__(self): return str(self.data) def __mul__(self, other): if self.size != other.size: print "error: different size" return tmp = Perm(self.size) for key in range(tmp.size): tmp.data[key] = self.data[other.data[key]] return tmp def __invert__(self): # ~p tmp = Perm(self.size) for i in range(tmp.size): tmp.data[self.data[i]] = i return tmp ------------------------------------------------------------------------------------- # Exemplary calculations N = 4 E = Perm(N) R1 = Perm(N,(0,1)) * Perm(N,(2,3)) R2 = Perm(N,(0,2)) * Perm(N,(1,3)) R3 = R1 * R2 # {E, R1, R2, R3} form D_2 group H = Perm(N,(0,1,3,2)) print H, ~H, H*(~H) ------------------------------------------------------------------------- Regards, Andrzej Kapanowski -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Fri Mar 11 11:42:33 2011 From: lac at openend.se (Laura Creighton) Date: Fri, 11 Mar 2011 11:42:33 +0100 Subject: [Edu-sig] Which shell to use In-Reply-To: Message from ray spiering of "Tue, 08 Mar 2011 08:23:16 PST." <914747.39923.qm@web31604.mail.mud.yahoo.com> References: <914747.39923.qm@web31604.mail.mud.yahoo.com> Message-ID: <201103111042.p2BAgX7W018655@theraft.openend.se> This can be fun to use - or at least I assume the 3.x version is as much fun as the 2.x version. http://ipython.scipy.org/moin/Python3 Laura From vceder at gmail.com Fri Mar 11 16:54:52 2011 From: vceder at gmail.com (Vern Ceder) Date: Fri, 11 Mar 2011 10:54:52 -0500 Subject: [Edu-sig] Dinner and a BoF Message-ID: Everyone at PyCon, I've reserved Hannover E (check the Open Space board to confirm that) for about 7:30 pm tonight (Friday). Since my talk is the last one of the day, and immediately follows the panel, we can figure out dinner plans then. If anyone has a suggestion or preference for a restaurant, that would be great. Cheers, Vern -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From kurner at oreillyschool.com Sat Mar 12 03:52:27 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Fri, 11 Mar 2011 18:52:27 -0800 Subject: [Edu-sig] Programming challenge: Message-ID: "=== makingmath.py ===" """ "make math your own" -- Maria Droujkova """ def makepi(): """stub function Ramanujan's freakish formula http://worldgame.blogspot.com/2008/02/reflective-fragment.html """ # using_gmpy() # using_decimal() # using_whatever() return 3.14 "=== test_pi.py ===" "OST programming challenge (more on FB)" import unittest import makingmath approx_pi = """3\ .141592653589793238462643383279502884197169399375 1058209749445923078164062862089986280348253421170 6798214808651328230664709384460955058223172535940 8128481117450284102701938521105559644622948954930 3819644288109756659334461284756482337867831652712 0190914564856692346034861045432664821339360726024 9141273724587006606315588174881520920962829254091 7153643678925903600113305305488204665213841469519 4151160943305727036575959195309218611738193261179 3105118548074462379962749567351885752724891227938 1830119491298336733624406566430860213949463952247 3719070217986094370277053921717629317675238467481 8467669405132000568127145263560827785771342757789 6091736371787214684409012249534301465495853710507 9227968925892354201995611212902196086403441815981 3629774771309960518707211349999998372978049951059 7317328160963185950244594553469083026425223082533 4468503526193118817101000313783875288658753320838 1420617177669147303598253490428755468731159562863 8823537875937519577818577805321712268066130019278 76611195909216420198 """.replace("\n","") class Test4Pi(unittest.TestCase): def test_thousand_digits(self): self.assertEquals(makingmath.makepi(), approx_pi, "Oops!") def _test(): print(approx_pi) if __name__ == "__main__": # _test() unittest.main( ) From sigzero at gmail.com Sat Mar 12 04:00:33 2011 From: sigzero at gmail.com (Robert) Date: Fri, 11 Mar 2011 22:00:33 -0500 Subject: [Edu-sig] Eclipse as Python3 IDE References: Message-ID: On 2010-06-27 18:03:56 -0400, kirby urner said: > Some of you may be familiar with the O'Reilly School of > Technology (OST) and its use of Eclipse as a front end to > accredited courses in the many languages, databases > and so on. > > Rather than use the free-standing Eclipse, which is an option, > you get a customized student version called Ellipse that > runs of their servers in a remote desktop session. > > This seems a creative approach and gets a next generation > of developer prepared with one of the state of the art environments, > using some of the best industry standard tools (e.g. Python > and MySQL). I can understand why they did it. They haven't won me over to eclipse though. I just find the interface too busy for my liking (although that could just be the way they ahve it setup for the school). If I am doing a few scripts I use Vim but I recently purchased PyCharm from the Jetbrains folks. I am really liking it. It is fairly new, but they are responsive to requests and have some nice features in the IDE (lots of Django integration, etc.). Anyway, choice is a good thing. :) -- Robert From kirby.urner at gmail.com Sat Mar 12 04:22:15 2011 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 11 Mar 2011 19:22:15 -0800 Subject: [Edu-sig] Eclipse as Python3 IDE In-Reply-To: References: Message-ID: > I can understand why they did it. They haven't won me over to eclipse > though. I just find the interface too busy for my liking (although that > could just be the way they ahve it setup for the school). If I am doing a > few scripts I use Vim but I recently purchased PyCharm from the Jetbrains > folks. I am really liking it. It is fairly new, but they are responsive to > requests and have some nice features in the IDE (lots of Django integration, > etc.). Anyway, choice is a good thing. ?:) > > -- > Robert > Thanks for the feedback Robert. When participants in the Python course ask me about IDEs, I point them to threads like this one. People have varying tastes, and if you're already a whiz at vim, why ever change? The OST use of Eclipse is more a ruthless repurposing, forcing it into the role of a server-side GUI for remote desktop use. They're repurposing Mathematica the same way (with permission), by devising a custom GUI for it (used at University of Illinois). Professors set up shop without requiring either student's or their host institutions to buy a Mathematica license, though many will opt to do this on their own anyway. Whereas I think this Eclipse / Ellipse based approach serves a worthwhile didactic purpose, it's not necessarily a "sales pitch" for Eclipse as the IDE of choice for one's personal use. PyDev is still evolving and users not needing exotic those plugins might be spared the inconvenience. Note: Eclipse is also the authoring system for the OST courseware, which is developed in XML with a licensed Oxygen plugin, and then transformed into PDF and XHTML for the end users. Kirby From vceder at gmail.com Sun Mar 13 03:36:32 2011 From: vceder at gmail.com (Vern Ceder) Date: Sat, 12 Mar 2011 21:36:32 -0500 Subject: [Edu-sig] PSF Brochure - call for submissions Message-ID: Hi everyone, In chatting with Charlie Clark and others today, it came up that we aren't doing as much as we might to promote the successes of Python in education. So I agreed to pass along to this list the call for content for the PSF brochure. Please feel free to write up your successes with Python and submit them. They will be considered for inclusion in the brochure as mentioned in the call for submissions below. Cheers, Vern Call for submissions for promotional brochure A new PSF project aims to create professional quality promotional material about Python. The first goal is to create a brochure to showcase the many ways Python is used. It will include use cases to highlight the ways the language allows users to accomplish their tasks both in educational and in professional settings. Project team members Marc-Andr? Lemburg, Jan Ulrich Hasecke, and Armin Stross-Radschinski created this Plone marketing brochure for the German Zope User Group. It is the inspiration for this new project. Community feedback and awareness is vitally important for the success of this initiative, mainly to gather information to be used in the brochure. We are especially looking for interesting projects that can be discussed as use-cases. If you have any suggestions for information to include in the brochure, please contact Marc-Andr? Lemburg or send an email to brochure AT getpython DOT info. UPDATE: more information about the brochure, including a newsletter, can be found here - http://brochure.getpython.info/ -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From kurner at oreillyschool.com Mon Mar 14 02:26:53 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Sun, 13 Mar 2011 18:26:53 -0700 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: References: Message-ID: On Sat, Mar 12, 2011 at 6:36 PM, Vern Ceder wrote: > Hi everyone, > > In chatting with Charlie Clark and others today, it came up that we > aren't doing as much as we might to promote the successes of Python in > education. So I agreed to pass along to this list the call for content > for the PSF brochure. Please feel free to write up your successes with > Python and submit them. They will be considered for inclusion in the > brochure as mentioned in the call for submissions below. > > Cheers, > Vern > > Call for submissions for promotional brochure > > A new PSF project aims to create professional quality promotional > material about Python. The first goal is to create a brochure to > showcase the many ways Python is used. It will include use cases to > highlight the ways the language allows users to accomplish their tasks > both in educational and in professional settings. > > Project team members Marc-Andr? Lemburg, Jan Ulrich Hasecke, and Armin > Stross-Radschinski created this Plone marketing brochure for the > German Zope User Group. It is the inspiration for this new project. > When you say "this Plone marketing brochure for the German Zope User Group" is that supposed to be a link? I'd be curious to see what that Plone brochure looks like. At first I wasn't clear if you meant something cyber, like Just Use It commercials (my thread on PSF list), or if this was to be printed on wood pulp, perhaps on glossy paper. I see it's to at least include the latter, but that doesn't rule out the former. > Community feedback and awareness is vitally important for the success > of this initiative, mainly to gather information to be used in the > brochure. We are especially looking for interesting projects that can > be discussed as use-cases. > Language communities need to produce their own free and open source commercials, with skills contributed by advertisers with state of the art skills, a way of giving back if they've been getting, -- and many of them have (used a LAMP stack lately?). I'll be nudging Wieden+Kennedy for ideas (local firm). I think companies like Holden Web and Open Bastion, Urban Airship, Rumblefish.... Jive all contribute to their respective language communities. Ruby has some especially cool flagships. But that's the commercial sector. What about NASA? And what about universities? Python at MIT: http://www.youtube.com/watch?v=SXR9CDof7qw&feature=related (I could tell he was from Canada, he confesses -- at 28:38 he says "I hate this language..." and says some nonsense about always using parens in place of brackets. Should we hassle this guy on Diversity? :) I remember that little pro Python PR clip made by Jeff Elkner's students, with that hippie dad in the basement, a girl showing her boyfriend how this language fit her brain. Now where was that again... ? Much more could be done... Why let Britney have all the fun? > If you have any suggestions for information to include in the > brochure, please contact Marc-Andr? Lemburg or send an email to > brochure AT getpython DOT info. > > UPDATE: more information about the brochure, including a newsletter, > can be found here - http://brochure.getpython.info/ > Quite a sophisticated front end to a worthy project I must say. A Portland school like Saturday Academy or LEP High could send along testimony and examples, proving how their curriculum was superior. Niche marketing. Would they have to pay for the free advertising? Of course not. Or... I should read more.... Here we go: """ The brochure will have 4 DIN A4 pages for ads. Ad sponsors can buy a half page ad for EUR 2,450.00 (+ VAT if applicable) in the first edition. Each ad sponsor will receive a box of around 120 free copies of the printed brochure after production. There is room for 8 ad sponsors. """ So will MIT be one of those sponsors? They could tout OLPC, a Python flagship as well. On another note, Pi Day is tomorrow. So far no takers at the OST web site. Looks like the Python solution might be the only solution to pass this unit test: http://mail.python.org/pipermail/edu-sig/2011-March/010224.html Not every language even has extended precision libraries, whereas Python has at least two that I know about. http://groups.google.com/group/mathfuture/browse_thread/thread/6c48dbcd8180e868?hl=en Is there anything about Pi Day at Pycon I wonder? How about a sprint in an open session? gmpy versus decimal anyone? I should get on twitter and follow the PSF snake... Kirby > -- > Vern Ceder > vceder at gmail.com, vceder at dogsinmotion.com > The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > Notes: I've posted this before, explains Britney allusion etc. http://www.4dsolutions.net/presentations/gis_2009_workshop.pdf From echerlin at gmail.com Mon Mar 14 03:42:35 2011 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 13 Mar 2011 22:42:35 -0400 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: References: Message-ID: On Sat, Mar 12, 2011 at 21:36, Vern Ceder wrote: > Hi everyone, > > In chatting with Charlie Clark and others today, it came up that we > aren't doing as much as we might to promote the successes of Python in > education. Do you have the OLPC XO Sugar software on your list? Almost all of it except Etoys (Smalltalk) and SimCity is in Python. Pippy is a limited Python IDE for children, and Turtle Art lets users call Python in any amount from a single function call to an application, providing an even easier starting point for students. I can provide endless detail. ^_^ > So I agreed to pass along to this list the call for content > for the PSF brochure. Please feel free to write up your successes with > Python and submit them. They will be considered for inclusion in the > brochure as mentioned in the call for submissions below. > > Cheers, > Vern > > Call for submissions for promotional brochure > > A new PSF project aims to create professional quality promotional > material about Python. The first goal is to create a brochure to > showcase the many ways Python is used. It will include use cases to > highlight the ways the language allows users to accomplish their tasks > both in educational and in professional settings. > > Project team members Marc-Andr? Lemburg, Jan Ulrich Hasecke, and Armin > Stross-Radschinski created this Plone marketing brochure for the > German Zope User Group. It is the inspiration for this new project. > > Community feedback and awareness is vitally important for the success > of this initiative, mainly to gather information to be used in the > brochure. We are especially looking for interesting projects that can > be discussed as use-cases. > > If you have any suggestions for information to include in the > brochure, please contact Marc-Andr? Lemburg or send an email to > brochure AT getpython DOT info. > > UPDATE: more information about the brochure, including a newsletter, > can be found here - http://brochure.getpython.info/ > > -- > Vern Ceder > vceder at gmail.com, vceder at dogsinmotion.com > The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From lac at openend.se Mon Mar 14 03:52:26 2011 From: lac at openend.se (Laura Creighton) Date: Mon, 14 Mar 2011 03:52:26 +0100 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: Message from Kirby Urner of "Sun, 13 Mar 2011 18:26:53 MST." References: Message-ID: <201103140252.p2E2qQnc005954@theraft.openend.se> I'm at pycon. Michael Sims of Nasa and the mars robots says he would be appy to be in the brochure. Nothing was said about piday. I forgot all about it. If you go to freenode and join #pycon you may catch sprinters interested in the challenge. Now me, tonight, at any rate. I am exhausted and must sleep. Laura From vceder at gmail.com Mon Mar 14 03:54:05 2011 From: vceder at gmail.com (Vern Ceder) Date: Sun, 13 Mar 2011 22:54:05 -0400 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: References: Message-ID: Hi Kirby, Missed seeing you here at PyCon... The link for the PSF brochure call for submissions is here: http://pyfound.blogspot.com/2011/03/call-for-submissions-for-promotional.html Charlie was pretty clear that they are intending a nice glossing brochure to give out to various audiences. They are looking for success stories from any and all arenas, but at this point, as far as Charlie put it, they don't really have any and they don't know exactly how to proceed. So you might direct your suggestions and feedback to those organizing the brochure. Vern On Sun, Mar 13, 2011 at 9:26 PM, Kirby Urner wrote: > On Sat, Mar 12, 2011 at 6:36 PM, Vern Ceder wrote: >> Hi everyone, >> >> In chatting with Charlie Clark and others today, it came up that we >> aren't doing as much as we might to promote the successes of Python in >> education. So I agreed to pass along to this list the call for content >> for the PSF brochure. Please feel free to write up your successes with >> Python and submit them. They will be considered for inclusion in the >> brochure as mentioned in the call for submissions below. >> >> Cheers, >> Vern >> >> Call for submissions for promotional brochure >> >> A new PSF project aims to create professional quality promotional >> material about Python. The first goal is to create a brochure to >> showcase the many ways Python is used. It will include use cases to >> highlight the ways the language allows users to accomplish their tasks >> both in educational and in professional settings. >> >> Project team members Marc-Andr? Lemburg, Jan Ulrich Hasecke, and Armin >> Stross-Radschinski created this Plone marketing brochure for the >> German Zope User Group. It is the inspiration for this new project. >> > > When you say "this Plone marketing brochure for the German Zope > User Group" is that supposed to be a link? > > I'd be curious to see what that Plone brochure looks like. > > At first I wasn't clear if you meant something cyber, like Just Use It > commercials (my thread on PSF list), or if this was to be printed on > wood pulp, perhaps on glossy paper. > > I see it's to at least include the latter, but that doesn't rule out the > former. > >> Community feedback and awareness is vitally important for the success >> of this initiative, mainly to gather information to be used in the >> brochure. We are especially looking for interesting projects that can >> be discussed as use-cases. >> > > Language communities need to produce their own free and open > source commercials, with skills contributed by advertisers with > state of the art skills, a way of giving back if they've been getting, > -- and many of them have (used a LAMP stack lately?). > > I'll be nudging Wieden+Kennedy for ideas (local firm). > > I think companies like Holden Web and Open Bastion, Urban Airship, > Rumblefish.... Jive all contribute to their respective language communities. > Ruby has some especially cool flagships. > > But that's the commercial sector. > > What about NASA? ?And what about universities? > > Python at MIT: > > http://www.youtube.com/watch?v=SXR9CDof7qw&feature=related > > (I could tell he was from Canada, he confesses -- at 28:38 he > says "I hate this language..." and says some nonsense about > always using parens in place of brackets. ?Should we hassle > this guy on Diversity? ?:) > > I remember that little pro Python PR clip made by Jeff Elkner's > students, with that hippie dad in the basement, a girl showing > her boyfriend how this language fit her brain. > > Now where was that again... ? > > Much more could be done... ?Why let Britney have all the fun? > > >> If you have any suggestions for information to include in the >> brochure, please contact Marc-Andr? Lemburg or send an email to >> brochure AT getpython DOT info. >> >> UPDATE: more information about the brochure, including a newsletter, >> can be found here - http://brochure.getpython.info/ >> > > Quite a sophisticated front end to a worthy project I must say. > > A Portland school like Saturday Academy or LEP High could > send along testimony and examples, proving how their > curriculum was superior. ?Niche marketing. > > Would they have to pay for the free advertising? ?Of course not. > Or... I should read more.... > > Here we go: > > """ > The brochure will have 4 DIN A4 pages for ads. > > Ad sponsors can buy a half page ad for EUR 2,450.00 (+ VAT if > applicable) in the first edition. > > Each ad sponsor will receive a box of around 120 free copies of the > printed brochure after production. > > There is room for 8 ad sponsors. > """ > > So will MIT be one of those sponsors? ?They could tout OLPC, > a Python flagship as well. > > On another note, Pi Day is tomorrow. ?So far no takers at the > OST web site. ?Looks like the Python solution might be the only > solution to pass this unit test: > > http://mail.python.org/pipermail/edu-sig/2011-March/010224.html > > Not every language even has extended precision libraries, whereas > Python has at least two that I know about. > > http://groups.google.com/group/mathfuture/browse_thread/thread/6c48dbcd8180e868?hl=en > > Is there anything about Pi Day at Pycon I wonder? ? How about a > sprint in an open session? ?gmpy versus decimal anyone? ?I should > get on twitter and follow the PSF snake... > > Kirby > > >> -- >> Vern Ceder >> vceder at gmail.com, vceder at dogsinmotion.com >> The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > Notes: > > I've posted this before, explains Britney allusion etc. > > http://www.4dsolutions.net/presentations/gis_2009_workshop.pdf > -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From vceder at gmail.com Mon Mar 14 03:55:40 2011 From: vceder at gmail.com (Vern Ceder) Date: Sun, 13 Mar 2011 22:55:40 -0400 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: References: Message-ID: On Sun, Mar 13, 2011 at 10:42 PM, Edward Cherlin wrote: > On Sat, Mar 12, 2011 at 21:36, Vern Ceder wrote: >> Hi everyone, >> >> In chatting with Charlie Clark and others today, it came up that we >> aren't doing as much as we might to promote the successes of Python in >> education. > > Do you have the OLPC XO Sugar software on your list? Almost all of it > except Etoys (Smalltalk) and SimCity is in Python. Pippy is a limited > Python IDE for children, and Turtle Art lets users call Python in any > amount from a single function call to an application, providing an > even easier starting point for students. I can provide endless detail. > ^_^ Well, it's not my list - I'm just publicizing the call for content as a favor. Please pass along any suggestions to those concerned. But I would *assume* that Sugar might be a candidate... Vern > >> So I agreed to pass along to this list the call for content >> for the PSF brochure. Please feel free to write up your successes with >> Python and submit them. They will be considered for inclusion in the >> brochure as mentioned in the call for submissions below. >> >> Cheers, >> Vern >> >> Call for submissions for promotional brochure >> >> A new PSF project aims to create professional quality promotional >> material about Python. The first goal is to create a brochure to >> showcase the many ways Python is used. It will include use cases to >> highlight the ways the language allows users to accomplish their tasks >> both in educational and in professional settings. >> >> Project team members Marc-Andr? Lemburg, Jan Ulrich Hasecke, and Armin >> Stross-Radschinski created this Plone marketing brochure for the >> German Zope User Group. It is the inspiration for this new project. >> >> Community feedback and awareness is vitally important for the success >> of this initiative, mainly to gather information to be used in the >> brochure. We are especially looking for interesting projects that can >> be discussed as use-cases. >> >> If you have any suggestions for information to include in the >> brochure, please contact Marc-Andr? Lemburg or send an email to >> brochure AT getpython DOT info. >> >> UPDATE: more information about the brochure, including a newsletter, >> can be found here - http://brochure.getpython.info/ >> >> -- >> Vern Ceder >> vceder at gmail.com, vceder at dogsinmotion.com >> The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From lac at openend.se Mon Mar 14 03:56:45 2011 From: lac at openend.se (Laura Creighton) Date: Mon, 14 Mar 2011 03:56:45 +0100 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: Message from Laura Creighton of "Mon, 14 Mar 2011 03:52:26 +0100." <201103140252.p2E2qQnc005954@theraft.openend.se> References: <201103140252.p2E2qQnc005954@theraft.openend.se> Message-ID: <201103140256.p2E2ujvb006433@theraft.openend.se> In a message of Mon, 14 Mar 2011 03:52:26 +0100, Laura Creighton writes: >I'm at pycon. Michael Sims of Nasa and the mars robots says he would be >appy to be in the brochure. Nothing was said about piday. I forgot s/appy/happy/ (Michael Sims is not French) >all about it. If you go to freenode and join #pycon you may catch >sprinters interested in the challenge. Now me, tonight, at any rate. s/Now/Not/ >I am exhausted and must sleep. that ++ > >Laura >_______________________________________________ >Edu-sig mailing list >Edu-sig at python.org >http://mail.python.org/mailman/listinfo/edu-sig From vceder at gmail.com Mon Mar 14 03:58:40 2011 From: vceder at gmail.com (Vern Ceder) Date: Sun, 13 Mar 2011 22:58:40 -0400 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: <201103140252.p2E2qQnc005954@theraft.openend.se> References: <201103140252.p2E2qQnc005954@theraft.openend.se> Message-ID: On Sun, Mar 13, 2011 at 10:52 PM, Laura Creighton wrote: > I'm at pycon. Michael Sims of Nasa and the mars robots says he would be > appy to be in the brochure. ?Nothing was said about piday. ?I forgot > all about it. ?If you go to freenode and join #pycon you may catch > sprinters interested in the challenge. ?Now me, tonight, at any rate. > I am exhausted and must sleep. > > Laura > I agree with Laura on both counts - the NASA story is a good one (look for the recording of his talk to be up soon) - and everyone here is pretty tired. Cheers, Vern -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From vceder at gmail.com Mon Mar 14 05:12:26 2011 From: vceder at gmail.com (Vern Ceder) Date: Mon, 14 Mar 2011 00:12:26 -0400 Subject: [Edu-sig] Videos of edu-sig talks at PyCon Message-ID: They have the videos of our talks up already! The panel is at http://pycon.blip.tv/file/4879118/ and my talk on Python and robots in high school is at http://pycon.blip.tv/file/4880794/ Both were received pretty well, I think. Cheers, Vern -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From juhasecke at googlemail.com Mon Mar 14 12:18:09 2011 From: juhasecke at googlemail.com (Jan Ulrich Hasecke) Date: Mon, 14 Mar 2011 12:18:09 +0100 Subject: [Edu-sig] PSF Brochure - call for submissions In-Reply-To: References: Message-ID: Hi Kirby, Am 14.03.11 02:26, schrieb Kirby Urner: > When you say "this Plone marketing brochure for the German Zope > User Group" is that supposed to be a link? > Yes, that was a link, it got lost somewhere. http://www.dzug.org/werbemittel/plone-das-professionelle-open-source-cms-fu308r-organisationen-und-unternehmen Thanks for your support! Jan Ulrich Hasecke -- The PSF Python Brochure Sign up to our newsletter! http://brochure.getpython.info/ From kurner at oreillyschool.com Mon Mar 14 19:27:57 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Mon, 14 Mar 2011 11:27:57 -0700 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: References: Message-ID: On Sun, Mar 13, 2011 at 9:12 PM, Vern Ceder wrote: > They have the videos of our talks up already! > > The panel is at http://pycon.blip.tv/file/4879118/ > > and my talk on Python and robots in high school is at > http://pycon.blip.tv/file/4880794/ > > Both were received pretty well, I think. > > Cheers, > Vern I watched yours in its entirety Vern, enjoyed. I like your enthusiasm, a loss to Canterbury that y'er moving on. I had no idea about these Georgia Tech robots. More comments later I think. Having these on BlipTV is a boon, as we can watch and discuss, like a book club. At the moment I'm in the middle of this one, Python and OpenGL. Right up my alley, I must say. I should contact this guy! http://pycon.blip.tv/file/4880794/ Looks like a great Pycon. psf_snake was frowning on Twitter, that it didn't get to go. http://worldgame.blogspot.com/2011/03/pycon-2011.html I'll post a solution to the "pi problem" here later... Kirby From sigzero at gmail.com Mon Mar 14 22:45:58 2011 From: sigzero at gmail.com (Robert) Date: Mon, 14 Mar 2011 17:45:58 -0400 Subject: [Edu-sig] [PyCon 2011] IDE Panel Message-ID: http://blogs.jetbrains.com/pycharm/2011/03/python-ides-panel-video-from-pycon-2011/ -- Robert From kurner at oreillyschool.com Mon Mar 14 23:16:41 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Mon, 14 Mar 2011 15:16:41 -0700 Subject: [Edu-sig] one solution (OST pi day challenge) Message-ID: """ "make math your own, to make your own math" -- Maria Droujkova See: http://mail.python.org/pipermail/edu-sig/2011-March/010224.html http://worldgame.blogspot.com/2011/03/pycon-2011.html http://groups.google.com/group/mathfuture/msg/4a847eb3cc12db77?hl=en """ def makepi(): """Pi to a thousand places Ramanujan's freakish formula http://worldgame.blogspot.com/2008/02/reflective-fragment.html """ # using_gmpy() thegen = ramanujan(4000) while True: term1 = next(thegen) term2 = next(thegen) if term1 == term2: # just lucky? break return str(term2)[:1001] # http://code.google.com/p/gmpy/ import gmpy # pre-installed binary gmpy2-2.0.0a1.win32-py3.1.exe def ramanujan(p=1000): gmpy.set_minprec(p) term = gmpy.fsqrt(gmpy.mpf(8))/gmpy.mpz(9801) n = gmpy.mpz(0) thesum = gmpy.mpz(0) while True: numer = (gmpy.fac(4*n)*(gmpy.mpz(1103) + gmpy.mpz(26390)*n)) denom = (gmpy.fac(n)**4)*(gmpy.mpz(396)**(4*n)) theterm = numer/denom thesum += theterm ans = term * thesum yield 1/ans n += 1 if __name__ == "__main__": print (makepi()) From kurner at oreillyschool.com Mon Mar 14 23:56:03 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Mon, 14 Mar 2011 15:56:03 -0700 Subject: [Edu-sig] another solution (OST pi day challenge) Message-ID: by Horacio Nunez and posted to the OST FB zone before the end of Pi Day: http://merthin.com/?p=159 (source code below) Congratulations Horacio, and happy Pi Day. That's 2 for Python. Score! OST ====== ##author: Horacio Nunez import decimal, math, functools D = decimal.Decimal C = decimal.getcontext() C.prec = 1024 def multiply(x,y): return C.multiply(x,y) def divide(x,y): return C.divide(x,y) def addition(x,y): return C.add(x,y) def power(x,y): return C.power(x,y) def sqrt(x): return C.sqrt(x) def factorial(n): result = 1 while n > 1: result *= n n = n - 1 return D(result) def Ramanujan(top): def serie(n): num = multiply(factorial(4 * n),addition(D(1103),multiply(D(26390),D(n)))) dem = multiply(power(factorial(n),D(4)),power(D(396),multiply(D(4),D(n)))) return divide(num,dem) Sum = functools.reduce((lambda x,y: addition(x,y)),map(serie,range(0,top))) return multiply(divide(multiply(D(2),sqrt(D(2))),D(9801)),Sum) def diff(str1,str2): if len(str1) != len(str2): return "Strings doesn't have the same length" else: for n in range(0,len(str1)): if str1[n] != str2[n]: return "They differ at " + str(n) + ": " + str1[n] + " != " + str2[n] return "They are equals!" approx_pi = D("""3.14159265358979323846264338327950288419716939937510582097494 4592307816406286208998628034825342117067982148086513282306647 0938446095505822317253594081284811174502841027019385211055596 4462294895493038196442881097566593344612847564823378678316527 1201909145648566923460348610454326648213393607260249141273724 5870066063155881748815209209628292540917153643678925903600113 3053054882046652138414695194151160943305727036575959195309218 6117381932611793105118548074462379962749567351885752724891227 9381830119491298336733624406566430860213949463952247371907021 7986094370277053921717629317675238467481846766940513200056812 7145263560827785771342757789609173637178721468440901224953430 1465495853710507922796892589235420199561121290219608640344181 5981362977477130996051870721134999999837297804995105973173281 6096318595024459455346908302642522308253344685035261931188171 0100031378387528865875332083814206171776691473035982534904287 5546873115956286388235378759375195778185778053217122680661300 1927876611195909216420198""".replace('\n','').replace(' ','')) result = Ramanujan(130); expected_fraction = str(divide(D(1),approx_pi))[:1001] actual_fraction = str(result)[:1001] expected_pi = str(approx_pi) actual_pi = str(divide(D(1),result))[:1001] print("Regarding 1/pi: " + diff(expected,actual)) print("Regarding pi: " + diff(expected_pi,actual_pi)) From vceder at gmail.com Tue Mar 15 05:08:34 2011 From: vceder at gmail.com (Vern Ceder) Date: Tue, 15 Mar 2011 00:08:34 -0400 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: References: Message-ID: On Mon, Mar 14, 2011 at 2:27 PM, Kirby Urner wrote: > On Sun, Mar 13, 2011 at 9:12 PM, Vern Ceder wrote: >> They have the videos of our talks up already! >> >> The panel is at http://pycon.blip.tv/file/4879118/ >> >> and my talk on Python and robots in high school is at >> http://pycon.blip.tv/file/4880794/ >> >> Both were received pretty well, I think. >> >> Cheers, >> Vern > > I watched yours in its entirety Vern, enjoyed. ?I like your > enthusiasm, a loss to Canterbury that y'er moving on. Thanks, Kirby! > > I had no idea about these Georgia Tech robots. > > More comments later I think. ?Having these on BlipTV is a boon, as we > can watch and discuss, like a book club. I agree... and the speed with which they've gotten them posted is amazing. > At the moment I'm in the middle of this one, Python and OpenGL. ?Right > up my alley, I must say. > > I should contact this guy! > > http://pycon.blip.tv/file/4880794/ > > Looks like a great Pycon. ?psf_snake was frowning on Twitter, that it > didn't get to go. Indeed, I would say it was probably the best ever... although not as much edu-sig as in past years... Vern > http://worldgame.blogspot.com/2011/03/pycon-2011.html > > I'll post a solution to the "pi problem" here later... > > Kirby > -- Vern Ceder vceder at gmail.com, vceder at dogsinmotion.com The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW From kirby.urner at gmail.com Fri Mar 18 04:50:51 2011 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 17 Mar 2011 20:50:51 -0700 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: References: Message-ID: >> I should contact this guy! >> >> http://pycon.blip.tv/file/4880794/ >> That's Vern's talk, which I liked. Then I should have linked to this OpenGL stuff, which is kinda like what I've been doing in VPython. http://blip.tv/file/4882916 But as of tonight, that talk in particular is down (not available). I hope this is a temporary situation. Been watching some of the panel on IDEs, need to get to the one about Python in teaching. Still lots to catch up on. Even if you got to go, there's a lotta rings in the circus. Asynch is the way to go. Kirby From kirby.urner at gmail.com Fri Mar 18 20:39:28 2011 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 18 Mar 2011 12:39:28 -0700 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: References: Message-ID: > > Then I should have linked to this OpenGL stuff, which is kinda like > what I've been doing in VPython. > > http://blip.tv/file/4882916 > > But as of tonight, that talk in particular is down (not available). ?I > hope this is a temporary situation. > Yep, definitely broken for others as well. ?We've made our comments on Disqus. Sigh: ?Python doing dancing polyhedrons has been so much what it's about for me. Trajectory: I came from Visual FoxPro (VFP), nowadays a sinking ship, looking for ways to write Scene Description Language to POV-Ray, the then free-on-CompuServ ray tracer (povray.org). Rendering Waterman Polyhedrons (named by me, invented by Steve Waterman) was one of my motivations back then, also explorations with "quadray coordinates"): http://dogfeathers.com/java/ccppoly.html (Java applet, not by me) http://en.wikipedia.org/wiki/Quadray_coordinates I journaled my journey, which took me through Java, and Bruce Eckel's famous writings, to like Python 1.6 I think it was: http://www.4dsolutions.net/ocn/oop.html (starting in VFP around 1998) http://www.4dsolutions.net/ocn/oop5.html (traversing through Java) http://www.4dsolutions.net/ocn/oop7.html (ending in Python) http://www.mindviewinc.com/Index.php (good mentor along the way) POV-Ray, VRML, LiveGraphics3D... all fill-in-the-blank type applications (for the views), drawing from computed data (the model). string.Template made sense, or nowadays just use the new formatting method. http://www.4dsolutions.net/ocn/numeracy0.html (POV-Ray etc.) Bridging Geometry and Geography then became the project, starting with bridging the lexical / graphical. Talk in Vilnius, Lithuania, giving some ideas. http://www.4dsolutions.net/presentations/connectingthedots.pdf (geography makes a splash towards the end -- "hexapent" refers to tiling a sphere with hexagons and pentagons). Getting our "education center" on Google Earth then became a job for property management clerk (recent): http://www.flickr.com/photos/17157315 at N00/5382897441/ (screen shot, Google Earth) http://www.flickr.com/photos/17157315 at N00/4083452440/ (FP at Laughing Horse Books) http://www.flickr.com/photos/17157315 at N00/3292180674/in/photostream/ (FP at Cleveland High School) http://www.flickr.com/photos/17157315 at N00/4674039162/in/photostream/ (FP in a Quaker classroom) Background: I hail from an esoteric school of thought (not necessarily always by choice) that features both a novel approach to polyhedrons, and an alternative world map projection. Having free and open source tools has meant staying in the game, at least a little, though we're still out-manned and out-gunned by the normals, not a new situation (standard Church of Subgenius talk). Anyway, I hope the OpenGL talk at Pycon 2011 comes back eventually. Why, of all the talks, would this one go away? Or maybe more did. Kirby > Been watching some of the panel on IDEs, need to get to the one about > Python in teaching. > > Still lots to catch up on. ?Even if you got to go, there's a lotta > rings in the circus. ?Asynch is the way to go. > > Kirby From calcpage at aol.com Sun Mar 20 00:02:00 2011 From: calcpage at aol.com (A. Jorge Garcia) Date: Sat, 19 Mar 2011 19:02:00 -0400 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: References: Message-ID: <8CDB4A0C9C88201-638-10A25@webmail-d139.sysops.aol.com> Wow, I would REALLY like to see this clip!!! Regards, A. Jorge Garcia Applied Math and CompSci http://shadowfaxrant.blogspot.com http://www.youtube.com/calcpage2009 -----Original Message----- From: kirby urner To: edu-sig at python.org Sent: Fri, Mar 18, 2011 3:39 pm Subject: Re: [Edu-sig] Videos of edu-sig talks at PyCon > > Then I should have linked to this OpenGL stuff, which is kinda like > what I've been doing in VPython. > > http://blip.tv/file/4882916 > > But as of tonight, that talk in particular is down (not available). ?I > hope this is a temporary situation. From kirby.urner at gmail.com Mon Mar 21 22:24:50 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 21 Mar 2011 14:24:50 -0700 Subject: [Edu-sig] Videos of edu-sig talks at PyCon In-Reply-To: <8CDB4A0C9C88201-638-10A25@webmail-d139.sysops.aol.com> References: <8CDB4A0C9C88201-638-10A25@webmail-d139.sysops.aol.com> Message-ID: Good news, this link has been fixed: http://pycon.blip.tv/file/4882916/ Great Pycon 2011 talk showing off a potentially bright future for Python where communicating about spatial geometry is concerned. About getting maximum value out of OpenGL by simplifying the API and using minimalist code, among other things. Kirby On Sat, Mar 19, 2011 at 4:02 PM, A. Jorge Garcia wrote: > Wow, I would REALLY like to see this clip!!! > > Regards, > A. Jorge Garcia > Applied Math and CompSci > http://shadowfaxrant.blogspot.com > http://www.youtube.com/calcpage2009 > > > -----Original Message----- > From: kirby urner > To: edu-sig at python.org > Sent: Fri, Mar 18, 2011 3:39 pm > Subject: Re: [Edu-sig] Videos of edu-sig talks at PyCon > >> >> Then I should have linked to this OpenGL stuff, which is kinda like >> what I've been doing in VPython. >> >> http://blip.tv/file/4882916 >> >> But as of tonight, that talk in particular is down (not available). ?I >> hope this is a temporary situation. > > > From kirby.urner at gmail.com Mon Mar 28 20:19:45 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 28 Mar 2011 11:19:45 -0700 Subject: [Edu-sig] looking for explanations... globals dynamic dict Message-ID: One of my Python students alerted me to this state of affairs. I understand that what globals( ) returns will fluctuate as new names come and go. What I less understand is why g isn't just a *snap shot* of what was global at the time globals( ) ran. Now it's just a dictionary like any other (and yes, it contains itself, as another global). So when I go to print its items, why should it care that the names k and v have been added. Why isn't g just a static dictionary? I guess because it's tied to a callable that gets re-executed whenever g is used. g.items( ) is like globals( ).items( ) -- another call. >>> g = globals() >>> g {'__builtins__': , '__name__': '__main__', '__doc__': None, 'g': {...}, '__package__': None} >>> len(g) 5 >>> for k, v in g.items(): print(k, v) __builtins__ Traceback (most recent call last): File "", line 1, in for k, v in g.items(): print(k, v) RuntimeError: dictionary changed size during iteration >>> g {'g': {...}, '__builtins__': , 'k': '__builtins__', '__package__': None, 'v': , '__name__': '__main__', '__doc__': None} >>> len(g) 7 >>> Oh no, not again.... >>> for t,v in g.items(): print(t,v) g {'g': {...}, '__builtins__': , 'k': '__builtins__', '__package__': None, 't': 'g', 'v': {...}, '__name__': '__main__', '__doc__': None} Traceback (most recent call last): File "", line 1, in for t,v in g.items(): print(t,v) RuntimeError: dictionary changed size during iteration This seems to solve the problem: >>> ================================ RESTART ================================ >>> g = dict(globals()) >>> g {'__builtins__': , '__name__': '__main__', '__doc__': None, '__package__': None} >>> for t,v in g.items(): print(t,v) __builtins__ __name__ __main__ __doc__ None __package__ None This behavior still seems a little peculiar. >>> help(globals) Help on built-in function globals in module builtins: globals(...) globals() -> dictionary Return the dictionary containing the current scope's global variables. -------------- next part -------------- An HTML attachment was scrubbed... URL: From john.zelle at wartburg.edu Mon Mar 28 21:15:14 2011 From: john.zelle at wartburg.edu (John Zelle) Date: Mon, 28 Mar 2011 19:15:14 +0000 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: References: Message-ID: Hello, Isn't the issue here simply that globals does not return a copy of the globals dictionary, it returns THE actual globals dictionary. It's not some sort of callable, it is the globals dictionary, period. There is no such thing as a static dictionary, they are mutable, and this one changes every time you define a new variable. For example, try: >>> g = globals() >>> g['k'] = 3 >>> k 3 So when you assign to new variables, this globals dictionary is changing, and that leads to the iteration error. As long as you iterate using existing variables, there is no problem. >>> g = globals() >>> k = None >>> v = None >>> for k,v in g.items(): ... print k,v ... g {'g': {...}, '__builtins__': , 'k': 'g', '__package__': None, 'v': {...}, '__name__': '__main__', '__doc__': None} __builtins__ k None __package__ None v None __name__ __main__ __doc__ None --John ________________________________ From: edu-sig-bounces+john.zelle=wartburg.edu at python.org [edu-sig-bounces+john.zelle=wartburg.edu at python.org] on behalf of kirby urner [kirby.urner at gmail.com] Sent: Monday, March 28, 2011 1:19 PM To: edu-sig at python.org Subject: [Edu-sig] looking for explanations... globals dynamic dict One of my Python students alerted me to this state of affairs. I understand that what globals( ) returns will fluctuate as new names come and go. What I less understand is why g isn't just a *snap shot* of what was global at the time globals( ) ran. Now it's just a dictionary like any other (and yes, it contains itself, as another global). So when I go to print its items, why should it care that the names k and v have been added. Why isn't g just a static dictionary? I guess because it's tied to a callable that gets re-executed whenever g is used. g.items( ) is like globals( ).items( ) -- another call. >>> g = globals() >>> g {'__builtins__': , '__name__': '__main__', '__doc__': None, 'g': {...}, '__package__': None} >>> len(g) 5 >>> for k, v in g.items(): print(k, v) __builtins__ Traceback (most recent call last): File "", line 1, in for k, v in g.items(): print(k, v) RuntimeError: dictionary changed size during iteration >>> g {'g': {...}, '__builtins__': , 'k': '__builtins__', '__package__': None, 'v': , '__name__': '__main__', '__doc__': None} >>> len(g) 7 >>> Oh no, not again.... >>> for t,v in g.items(): print(t,v) g {'g': {...}, '__builtins__': , 'k': '__builtins__', '__package__': None, 't': 'g', 'v': {...}, '__name__': '__main__', '__doc__': None} Traceback (most recent call last): File "", line 1, in for t,v in g.items(): print(t,v) RuntimeError: dictionary changed size during iteration This seems to solve the problem: >>> ================================ RESTART ================================ >>> g = dict(globals()) >>> g {'__builtins__': , '__name__': '__main__', '__doc__': None, '__package__': None} >>> for t,v in g.items(): print(t,v) __builtins__ __name__ __main__ __doc__ None __package__ None This behavior still seems a little peculiar. >>> help(globals) Help on built-in function globals in module builtins: globals(...) globals() -> dictionary Return the dictionary containing the current scope's global variables. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdipierro at cs.depaul.edu Mon Mar 28 21:28:06 2011 From: mdipierro at cs.depaul.edu (Massimo Di Pierro) Date: Mon, 28 Mar 2011 14:28:06 -0500 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: References: Message-ID: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> In python variables assigned to dict and list are always references. >>> a = {} >>> b = a # b and a point to the same dictionary >>> b['key'] = 'value' >>> print a['key'] value primitive types like integers behave differently >>> a = 1 >>> b = a # b and a are two different 1s >>> b+=2 >>> print a 1 You can copy the objects copied by a reference >>> a = {} >>> import copy >>> b = copy.deepcopy(a) # b is a complete copy of a (also objects in keys and values are copied recursively) >>> b['key'] = 'value' >>> print a['key'] KeyError On Mar 28, 2011, at 2:15 PM, John Zelle wrote: > Hello, > > Isn't the issue here simply that globals does not return a copy of > the globals dictionary, it returns THE actual globals dictionary. > It's not some sort of callable, it is the globals dictionary, > period. There is no such thing as a static dictionary, they are > mutable, and this one changes every time you define a new variable. > For example, try: > > >>> g = globals() > >>> g['k'] = 3 > >>> k > 3 > > So when you assign to new variables, this globals dictionary is > changing, and that leads to the iteration error. As long as you > iterate using existing variables, there is no problem. > > >>> g = globals() > >>> k = None > >>> v = None > >>> for k,v in g.items(): > ... print k,v > ... > g {'g': {...}, '__builtins__': , > 'k': 'g', '__package__': None, 'v': {...}, '__name__': '__main__', > '__doc__': None} > __builtins__ > k None > __package__ None > v None > __name__ __main__ > __doc__ None > > > --John > > > From: edu-sig-bounces+john.zelle=wartburg.edu at python.org [edu-sig-bounces+john.zelle=wartburg.edu at python.org > ] on behalf of kirby urner [kirby.urner at gmail.com] > Sent: Monday, March 28, 2011 1:19 PM > To: edu-sig at python.org > Subject: [Edu-sig] looking for explanations... globals dynamic dict > > > One of my Python students alerted me to this state of affairs. > > I understand that what globals( ) returns will fluctuate as new > names come and go. > > What I less understand is why g isn't just a *snap shot* of what was > global at the time globals( ) ran. > > Now it's just a dictionary like any other (and yes, it contains > itself, as another global). > > So when I go to print its items, why should it care that the names k > and v have been added. > > Why isn't g just a static dictionary? > > I guess because it's tied to a callable that gets re-executed > whenever g is used. g.items( ) is like globals( ).items( ) -- > another call. > > > >>> g = globals() > >>> g > {'__builtins__': , '__name__': > '__main__', '__doc__': None, 'g': {...}, '__package__': None} > >>> len(g) > 5 > >>> for k, v in g.items(): print(k, v) > > __builtins__ > Traceback (most recent call last): > File "", line 1, in > for k, v in g.items(): print(k, v) > RuntimeError: dictionary changed size during iteration > >>> g > {'g': {...}, '__builtins__': , 'k': > '__builtins__', '__package__': None, 'v': in)>, '__name__': '__main__', '__doc__': None} > >>> len(g) > 7 > >>> > > > Oh no, not again.... > > >>> for t,v in g.items(): print(t,v) > > g {'g': {...}, '__builtins__': , 'k': > '__builtins__', '__package__': None, 't': 'g', 'v': {...}, > '__name__': '__main__', '__doc__': None} > Traceback (most recent call last): > File "", line 1, in > for t,v in g.items(): print(t,v) > RuntimeError: dictionary changed size during iteration > > This seems to solve the problem: > > >>> ================================ RESTART > ================================ > >>> g = dict(globals()) > >>> g > {'__builtins__': , '__name__': > '__main__', '__doc__': None, '__package__': None} > >>> for t,v in g.items(): print(t,v) > > __builtins__ > __name__ __main__ > __doc__ None > __package__ None > > > This behavior still seems a little peculiar. > > >>> help(globals) > Help on built-in function globals in module builtins: > > globals(...) > globals() -> dictionary > > Return the dictionary containing the current scope's global > variables. > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Mon Mar 28 21:42:45 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 28 Mar 2011 12:42:45 -0700 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: References: Message-ID: Good hearing from you John. It's interesting to compare globals( ) with dir( ). That latter is affected by the new names in a for loop but doesn't reflect these changes until later, whereas globals( ) raises an exception. The globals dict seems an unusual beast. Interesting recursivity too. >>> g = globals() >>> g['g']['g']['g']['g']['g']['g']['g']['g']['g'] {'__builtins__': , '__name__': '__main__', '__doc__': None, 'g': {...}, '__package__': None} I call it "flat recursivity" in that we're not looking at successive frames on some stack. Hmmm, just stumbled upon (is "recursivity" a word?): http://recursed.blogspot.com/ Kirby >>> ================================ RESTART ================================ >>> g = dict(globals()) >>> g {'__builtins__': , '__name__': '__main__', '__doc__': None, '__package__': None} >>> for t,v in g.items(): print(t,v) __builtins__ __name__ __main__ __doc__ None __package__ None >>> help(globals) Help on built-in function globals in module builtins: globals(...) globals() -> dictionary Return the dictionary containing the current scope's global variables. >>> d = dir() >>> for v in d: print(v) __builtins__ __doc__ __name__ __package__ g t v >>> ================================ RESTART ================================ >>> d = dir() >>> for v in d: print(v) __builtins__ __doc__ __name__ __package__ >>> g = globals() >>> for v in g: print(v) d g __builtins__ __package__ v __name__ __doc__ >>> ================================ RESTART ================================ >>> g = globals() >>> for v in g: print(v) __builtins__ Traceback (most recent call last): File "", line 1, in for v in g: print(v) RuntimeError: dictionary changed size during iteration >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'g', 'v'] >>> ================================ RESTART ================================ >>> d = dir() >>> for v in d: print(v) __builtins__ __doc__ __name__ __package__ >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'd', 'v'] >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Mon Mar 28 22:29:56 2011 From: lac at openend.se (Laura Creighton) Date: Mon, 28 Mar 2011 22:29:56 +0200 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: Message from kirby urner of "Mon, 28 Mar 2011 11:19:45 PDT." References: Message-ID: <201103282029.p2SKTuGf029216@theraft.openend.se> In a message of Mon, 28 Mar 2011 11:19:45 PDT, kirby urner writes: >--===============0915739999== >Content-Type: multipart/alternative; boundary=20cf303b3f9bfa4ea5049f8efcd >What I less understand is why g isn't just a *snap shot* of what was global >at the time globals( ) ran. Because you didn't bind g to a copy of the global dictionary at time t. You bound it to the global dictionary itself. Laura From kirby.urner at gmail.com Mon Mar 28 22:48:05 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 28 Mar 2011 13:48:05 -0700 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <201103282029.p2SKTuGf029216@theraft.openend.se> References: <201103282029.p2SKTuGf029216@theraft.openend.se> Message-ID: On Mon, Mar 28, 2011 at 1:29 PM, Laura Creighton wrote: > In a message of Mon, 28 Mar 2011 11:19:45 PDT, kirby urner writes: > >--===============0915739999== > >Content-Type: multipart/alternative; boundary=20cf303b3f9bfa4ea5049f8efcd > > >What I less understand is why g isn't just a *snap shot* of what was > global > >at the time globals( ) ran. > > Because you didn't bind g to a copy of the global dictionary at time t. > You bound it to the global dictionary itself. > > Laura > Yes, and the contents of that dict change as a side effect of assignment in the global namespace. When I bind to dir( ) at time t, there's no mutating dict on the other end of the line, just a snap shot. >>> ================================ RESTART ================================ >>> d = dir() >>> d ['__builtins__', '__doc__', '__name__', '__package__'] >>> v = 14 >>> d ['__builtins__', '__doc__', '__name__', '__package__'] >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'd', 'v'] Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From carl at free.org.nz Mon Mar 28 22:59:40 2011 From: carl at free.org.nz (Carl Cerecke) Date: Tue, 29 Mar 2011 09:59:40 +1300 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> Message-ID: On 29 March 2011 08:28, Massimo Di Pierro wrote: > > primitive types like integers behave differently > > >>> a = 1 > >>> b = a # b and a are two different 1s > >>> b+=2 > >>> print a > 1 > > > Well, not really. Although I see what you are trying to say. numbers (like strings) are immutable. There can ever be only one number 1. You can't change a number to something else. If add 5 to 3, the number 3 doesn't change, I get a new number, 8. with "a = 1", python is still using a reference to an object. You can see this because ints have methods: >>> a = 1 >>> a.__add__ >>> a.__add__(5) 6 >>> a 1 After a 'b = a' statement, b and a point to the same object (in this case, the one at 0x009ADD38): >>> b = a >>> b.__add__ >>> Remember, the object that both b and a reference is immutable. It's the number 1. You can't change the number one to be some other number. If you then do 'b += 2', python calculates the result of the expression 'b + 2', which is 3, and then changes b's reference to point to the object representing the int 3. Cheers, Carl. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Mon Mar 28 23:25:00 2011 From: lac at openend.se (Laura Creighton) Date: Mon, 28 Mar 2011 23:25:00 +0200 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: Message from Carl Cerecke of "Tue, 29 Mar 2011 09:59:40 +1300." References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> Message-ID: <201103282125.p2SLP0kX002359@theraft.openend.se> In a message of Tue, 29 Mar 2011 09:59:40 +1300, Carl Cerecke writes: >Well, not really. Although I see what you are trying to say. >numbers (like strings) are immutable. There can ever be only one number 1 >You can't change a number to something else. If add 5 to 3, the number 3 >doesn't change, I get a new number, 8. This is merely an implementation detail. Python 2.6.6 Type "help", "copyright", "credits" or "license" for more information. >>> w = 1 >>> y = 1 >>> w is y # this might surprise you True [PyPy 1.4.1] Type "help", "copyright", "credits" or "license" for more information. >>>> w = 1 >>>> y = 1 >>>> w is y # or are you so used to CPython that this surprises you? False You can have as many number ones as you like. In CPython they are cached to be the same object, but you shouldn't rely on that behaviour. It's actually pretty dodgy to test the object identity on immutable objects -- unless you want to surprise people like I tried to. Incidentally Python 2.6.6 Type "help", "copyright", "credits" or "license" for more information. >>> w = 5234 >>> y = 5324 >>> w is y False so after a certain point, the CPython developers have decided that the performance gains of cacheing all number xs as the same x isn't worth it. Laura From carl at free.org.nz Tue Mar 29 00:49:08 2011 From: carl at free.org.nz (Carl Cerecke) Date: Tue, 29 Mar 2011 11:49:08 +1300 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <201103282125.p2SLP0kX002359@theraft.openend.se> References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> Message-ID: Yes. Laura, you're correct. I'll try again: Massimo was trying to say that after: a = 1 b = a b and a refer to *different* 'one's because changing one of them (b += 2) doesn't change the other. This isn't true. They refer to the same 'one' object (regardless of python implementation). b += 2 doesn't change the 'one' object, but simply points b to a 'three' object. There. How's that? Carl. On 29 March 2011 10:25, Laura Creighton wrote: > In a message of Tue, 29 Mar 2011 09:59:40 +1300, Carl Cerecke writes: > >Well, not really. Although I see what you are trying to say. > > >numbers (like strings) are immutable. There can ever be only one number 1 > >You can't change a number to something else. If add 5 to 3, the number 3 > >doesn't change, I get a new number, 8. > > This is merely an implementation detail. > > Python 2.6.6 > Type "help", "copyright", "credits" or "license" for more information. > >>> w = 1 > >>> y = 1 > >>> w is y # this might surprise you > True > > [PyPy 1.4.1] > Type "help", "copyright", "credits" or "license" for more information. > > >>>> w = 1 > >>>> y = 1 > >>>> w is y # or are you so used to CPython that this surprises you? > False > > You can have as many number ones as you like. In CPython they are > cached to be the same object, but you shouldn't rely on that behaviour. > It's actually pretty dodgy to test the object identity on immutable > objects -- unless you want to surprise people like I tried to. > > Incidentally > > Python 2.6.6 > Type "help", "copyright", "credits" or "license" for more information. > >>> w = 5234 > >>> y = 5324 > >>> w is y > False > > so after a certain point, the CPython developers have decided that the > performance gains of cacheing all number xs as the same x isn't worth > it. > > Laura > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lac at openend.se Tue Mar 29 02:02:06 2011 From: lac at openend.se (Laura Creighton) Date: Tue, 29 Mar 2011 02:02:06 +0200 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: Message from Carl Cerecke of "Tue, 29 Mar 2011 11:49:08 +1300." References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> Message-ID: <201103290002.p2T026NG017090@theraft.openend.se> In a message of Tue, 29 Mar 2011 11:49:08 +1300, Carl Cerecke writes: >--20cf307abcff67e7bc049f92c049 >Content-Type: text/plain; charset=ISO-8859-1 > >Yes. Laura, you're correct. I'll try again: > >Massimo was trying to say that after: >a = 1 >b = a > >b and a refer to *different* 'one's because changing one of them (b += 2) >doesn't change the other. > >This isn't true. They refer to the same 'one' object (regardless of pytho >n >implementation). b += 2 doesn't change the 'one' object, but simply point >s b >to a 'three' object. > >There. How's that? > >Carl. Incorrect, I think. When I am talking about 'the same 'one' object', what I mean is not some sort of philosophical one-ness, some Platonic ideal of one, which like all the numbers, is a singleton, wherever it occurs in the universe. I mean something much more concrete than that. Somewhere in my computer are addressable pieces of memory, and in those locations are values. When I say that two variables are bound to the same object I mean they refer to that exact same piece of memory right there. (We will ignore, for the purpose of this discussion, issues related to garbage collectors that move objects around. Because its the job of the gc writer to make sure that after the collection happens, all of those references to the old memory location all point to the new memory location. So the location is different, but the property that all variables bound to the same object get the same location in memory remains true.) Consider what happens when your memory goes bad. Stray alpha particle, or (more likely) just a bad bit of memory. I've typed: >>> w = 1 >>> y = 1 >>> z = 1 suddenly, a bit of memory goes bad, the chunk that w is bound to. Instead of containing 1, it contains 2. What happens? Well, in CPython, w is now bound to the value 2. So is y and z. And I will bet that CPython will fall over and die a horrible death. All the places where it internally uses the value '1' will get the wrong value. But this is an implementation detail. But in PyPy, when the chunk that w is bound to goes bad, y and z, which were bound to entirely different pieces of memory, still have good values in them. Assuming that w is not something that PyPy uses internally, it is entirely possible that things could go on seemingly fine. Should w be in the code you typed at an interactive PyPy interpreter, you may be amazed and perplexed when you type: >>>> w = 1 # that memory location goes bad right now! >>>> w + w 4 Not the result you expected. You'd complain pypy was broken, and if it kept happening (i.e. it was a bug, not bad memory) you'd be correct. --------------- What I think you are trying to say is that you cannot change the values of immutable objects. Which is very true. (Barring disasters with bad memory and alpha particles and the like.) But this has nothing to do with how many immutable objects share the same value. It has to do with the fact that you cannot mutate immutable objects. >>>> a = 1 >>>> a = 2 >>>> a = "horseradish" All I have done is changed a's bindings. No walking out to memory, making a chunk of it mean '1', and binding a to it, then walking about again, finding the same bit of memory, and scribbling on it so it means '2', and then walking out and scribbling on it to mean 'horseradish'. That doesn't happen. as opposed to: >>>> a = [1] >>>> b = a >>>> a.append(2) >>>> b [1, 2] a.append(2) really did walk out into memory, find the bit that a was bound to, and scribbled on it so that where it once said [1] it now says [1, 2] Since b is bound to the same bit of memory, it changes too. Laura From kirby.urner at gmail.com Tue Mar 29 02:19:47 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 28 Mar 2011 17:19:47 -0700 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <201103290002.p2T026NG017090@theraft.openend.se> References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> <201103290002.p2T026NG017090@theraft.openend.se> Message-ID: On Mon, Mar 28, 2011 at 5:02 PM, Laura Creighton wrote: > Incorrect, I think. When I am talking about 'the same 'one' object', > what I mean is not some sort of philosophical one-ness, some Platonic > ideal of one, which like all the numbers, is a singleton, wherever it > occurs in the universe. I mean something much more concrete than > that. > Loved your really explicit and detailed reply there Laura. On a student quiz I'd write "Good and complete answer!". Kirby Footnote to Plato: Not being a Platonist in the sense of nominalist (the two schools are usually counter-posed, but not here), I don't see a need for some "essential meaning" of "oneness". Lots of partially overlapping use cases bearing a family resemblance to one another is sufficient to anchor one's meaning. -------------- next part -------------- An HTML attachment was scrubbed... URL: From carl at free.org.nz Tue Mar 29 02:27:20 2011 From: carl at free.org.nz (Carl Cerecke) Date: Tue, 29 Mar 2011 13:27:20 +1300 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <201103290002.p2T026NG017090@theraft.openend.se> References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> <201103290002.p2T026NG017090@theraft.openend.se> Message-ID: At the risk of boring the other readers.... Yes. You are right. But so was I (on the second time around): a=1 b=1 a and b could refer to the same object or different objects with the same value. It depends on implementation details. I agree here. a=1 b=a a and b refer to the *same* object here regardless of implementation. Massimo said they were different, because b+= 2 doesn't change a. That statement is incorrect. That's really all I was trying to say. I wasn't trying to be philsophical about Platonic singleness in the universe or whatever. Cheers, Carl. On 29 March 2011 13:02, Laura Creighton wrote: > In a message of Tue, 29 Mar 2011 11:49:08 +1300, Carl Cerecke writes: > >--20cf307abcff67e7bc049f92c049 > >Content-Type: text/plain; charset=ISO-8859-1 > > > >Yes. Laura, you're correct. I'll try again: > > > >Massimo was trying to say that after: > >a = 1 > >b = a > > > >b and a refer to *different* 'one's because changing one of them (b += 2) > >doesn't change the other. > > > >This isn't true. They refer to the same 'one' object (regardless of pytho > >n > >implementation). b += 2 doesn't change the 'one' object, but simply point > >s b > >to a 'three' object. > > > >There. How's that? > > > >Carl. > > Incorrect, I think. When I am talking about 'the same 'one' object', > what I mean is not some sort of philosophical one-ness, some Platonic > ideal of one, which like all the numbers, is a singleton, wherever it > occurs in the universe. I mean something much more concrete than > that. Somewhere in my computer are addressable pieces of memory, and > in those locations are values. When I say that two variables are > bound to the same object I mean they refer to that exact same piece of > memory right there. (We will ignore, for the purpose of this > discussion, issues related to garbage collectors that move objects > around. Because its the job of the gc writer to make sure that after > the collection happens, all of those references to the old memory > location all point to the new memory location. So the location is > different, but the property that all variables bound to the same object > get the same location in memory remains true.) > > Consider what happens when your memory goes bad. Stray alpha particle, or > (more likely) just a bad bit of memory. > > I've typed: > > >>> w = 1 > >>> y = 1 > >>> z = 1 > > suddenly, a bit of memory goes bad, the chunk that w is bound to. Instead > of containing 1, it contains 2. > > What happens? > Well, in CPython, w is now bound to the value 2. So is y and z. And > I will bet that CPython will fall over and die a horrible death. All > the places where it internally uses the value '1' will get the wrong > value. But this is an implementation detail. > > But in PyPy, when the chunk that w is bound to goes bad, y and z, which > were bound to entirely different pieces of memory, still have good values > in them. Assuming that w is not something that PyPy uses internally, it > is entirely possible that things could go on seemingly fine. Should w > be in the code you typed at an interactive PyPy interpreter, you may be > amazed and perplexed when you type: > > >>>> w = 1 # that memory location goes bad right now! > >>>> w + w > 4 > > Not the result you expected. You'd complain pypy was broken, and if > it kept happening (i.e. it was a bug, not bad memory) you'd be correct. > > --------------- > What I think you are trying to say is that you cannot change the values of > immutable objects. Which is very true. (Barring disasters with bad memory > and alpha particles and the like.) But this has nothing to do with how > many immutable objects share the same value. It has to do with the fact > that you cannot mutate immutable objects. > > >>>> a = 1 > >>>> a = 2 > >>>> a = "horseradish" > > All I have done is changed a's bindings. No walking out to memory, making > a > chunk of it mean '1', and binding a to it, then walking about again, > finding > the same bit of memory, and scribbling on it so it means '2', and then > walking out and scribbling on it to mean 'horseradish'. That doesn't > happen. > > as opposed to: > > >>>> a = [1] > >>>> b = a > >>>> a.append(2) > >>>> b > [1, 2] > > a.append(2) really did walk out into memory, find the bit that a was bound > to, and scribbled on it so that where it once said [1] it now says [1, 2] > Since b is bound to the same bit of memory, it changes too. > > Laura > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From goldwamh at slu.edu Tue Mar 29 00:23:45 2011 From: goldwamh at slu.edu (Michael H. Goldwasser) Date: Mon, 28 Mar 2011 17:23:45 -0500 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: <201103282125.p2SLP0kX002359@theraft.openend.se> References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> Message-ID: <19857.2673.183945.754040@euclid.local> On Monday March 28, 2011, Laura Creighton wrote: > In a message of Tue, 29 Mar 2011 09:59:40 +1300, Carl Cerecke writes: > >Well, not really. Although I see what you are trying to say. > > >numbers (like strings) are immutable. There can ever be only one number 1 > >You can't change a number to something else. If add 5 to 3, the number 3 > >doesn't change, I get a new number, 8. > > This is merely an implementation detail. Note well that the issue has changed since the original post. The question at the time concerned the following code >>> a = 1 >>> b = a # b and a are two different 1s Carl correctly points out that b and a are not two different 1s in this case. The assignment statment of a = b has the same semantics for integers as it does for any other data type. a and b become aliases for the same underlying instance. On any platform, it will be the case that >>> a is b True folowing that assignment. The original misunderstanding involved the semantics of b += 2; that command does not mutate the underlying instance, but re-associates the identifier b to a new value (while a remains associated with the value 1). In your reply, the code fragment (below) shows a different issue regarding the re-use of integer literals in source code (as you assigned b=1 rather than b=a). In that case, it is system-dependent whether the interpretter uses different instances or the same instance, and you are right that there is no guarantee that equivalent instances will be identical instances. With regard, Michael > > Python 2.6.6 > Type "help", "copyright", "credits" or "license" for more information. > >>> w = 1 > >>> y = 1 > >>> w is y # this might surprise you > True > > [PyPy 1.4.1] > Type "help", "copyright", "credits" or "license" for more information. > > >>>> w = 1 > >>>> y = 1 > >>>> w is y # or are you so used to CPython that this surprises you? > False > > You can have as many number ones as you like. In CPython they are > cached to be the same object, but you shouldn't rely on that behaviour. > It's actually pretty dodgy to test the object identity on immutable > objects -- unless you want to surprise people like I tried to. > > Incidentally > > Python 2.6.6 > Type "help", "copyright", "credits" or "license" for more information. > >>> w = 5234 > >>> y = 5324 > >>> w is y > False > > so after a certain point, the CPython developers have decided that the > performance gains of cacheing all number xs as the same x isn't worth > it. > > Laura +----------------------------------------------- | Michael H. Goldwasser, Ph.D. | Associate Professor | Director of Computer Science | Dept. Mathematics and Computer Science | Saint Louis University | 220 North Grand Blvd. | St. Louis, MO 63103-2007 | | Office: Ritter Hall 108 | Email: goldwamh at slu.edu | URL: http://cs.slu.edu/~goldwasser | Phone: (314) 977-7039 | Fax: (314) 977-1452 From lac at openend.se Tue Mar 29 05:01:49 2011 From: lac at openend.se (Laura Creighton) Date: Tue, 29 Mar 2011 05:01:49 +0200 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: Message from Carl Cerecke of "Tue, 29 Mar 2011 13:27:20 +1300." References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> <201103290002.p2T026NG017090@theraft.openend.se> Message-ID: <201103290301.p2T31nqG000541@theraft.openend.se> In a message of Tue, 29 Mar 2011 13:27:20 +1300, Carl Cerecke writes: >Yes. You are right. But so was I (on the second time around): > >a=1 >b=1 > >a and b could refer to the same object or different objects with the same >value. It depends on implementation details. I agree here. > >a=1 >b=a > >a and b refer to the *same* object here regardless of implementation. >Massimo said they were different, because b+= 2 doesn't change a. That >statement is incorrect. > >That's really all I was trying to say. I wasn't trying to be philsophical >about Platonic singleness in the universe or whatever. > >Cheers, >Carl. Ok. I still found the way you said that confusing. Sorry about that. Laura From kirby.urner at gmail.com Tue Mar 29 06:07:56 2011 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 28 Mar 2011 21:07:56 -0700 Subject: [Edu-sig] looking for explanations... globals dynamic dict In-Reply-To: References: <06199862-8AA4-42A5-9DDB-E990C6EBE234@cs.depaul.edu> <201103282125.p2SLP0kX002359@theraft.openend.se> <19857.2673.183945.754040@euclid.local> Message-ID: On Mon, Mar 28, 2011 at 3:23 PM, Michael H. Goldwasser wrote: > > > Note well that the issue has changed since the original post. The > question at the time concerned the following code > > Not to quibble, but the issue of the *original* post had to do with assignments (such as those below) dynamically mutating an "environment dict" named globals(). What this function returns varies moment to moment as a side effect of new assignment operations top level, or deletions. dir(), on the other hand, returns a snapshot, a "static" list (not that lists are static in the sense of immutable -- not what I meant). One could imagine a globals() that *did* return a snapshot, as dict(globals()) does. >>> g = dict(globals()) >>> for k,v in g.items(): print(k,v, sep=":") # no problemo __builtins__: __name__:__main__ __doc__:None __package__:None >>> a = 1 > >>> b = a # b and a are two different 1s > > Carl correctly points out that b and a are not two different 1s in > this case. The assignment statment of a = b has the same semantics for > integers as it does for any other data type. a and b become aliases > for the same underlying instance. On any platform, it will be the > case that > > >>> a is b > True > > folowing that assignment. Very true and related to Python's bias against unnecessary copying, making copy (as a verb) live inside its own module (like in a dog house) not even present as a built-in. This is because names are light and airy whereas the objects they name on the heap may be gargantuan, in terms of resources used. green = Giant( ); red = green should not inadvertently cause two instances of Giant, with copying a side effect of assignment. As a language, Python is refreshingly consistent about not doing that. > The original misunderstanding involved the > semantics of b += 2; that command does not mutate the underlying > instance, but re-associates the identifier b to a new value (while a > remains associated with the value 1). > Likewise I get students talking about how "hello world".upper( ) is "transforming" a string, whereas more accurately its returning a new string instance that's based on "hello world" -- like transcribing DNA, building a protein. So is "transcribing" to go back to inadvertent copying? No, because a = "hello world"; b = a.upper( ) is about creating two different strings, each with its own name. No copies here. > > In your reply, the code fragment (below) shows a different issue > regarding the re-use of integer literals in source code (as you > assigned b=1 rather than b=a). In that case, it is system-dependent > whether the interpretter uses different instances or the same > instance, and you are right that there is no guarantee that equivalent > instances will be identical instances. > >>> (17 + 1) is 18 True >>> 8243985209384708709180298734 is (8243985209384708709180298733 + 1) False Implementation details... Kirby > > With regard, > Michael > > > > > Python 2.6.6 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> w = 1 > > >>> y = 1 > > >>> w is y # this might surprise you > > True > > > > [PyPy 1.4.1] > > Type "help", "copyright", "credits" or "license" for more information. > > > > >>>> w = 1 > > >>>> y = 1 > > >>>> w is y # or are you so used to CPython that this surprises you? > > False > -------------- next part -------------- An HTML attachment was scrubbed... URL: From goldwamh at slu.edu Tue Mar 29 07:06:50 2011 From: goldwamh at slu.edu (Michael H. Goldwasser) Date: Tue, 29 Mar 2011 00:06:50 -0500 Subject: [Edu-sig] Interesting "gotcha" Message-ID: <19857.26858.803608.154614@euclid.local> To start a new thread, I'm always trying to keep a list of some common "gotchas" that beginning students run across when using Python, or things that teachers should keep in mind when teaching with the language. I have in mind commands that do not generate runtime errors, but are likely to lead to logical errors that are not apparent to students, and most of these are legal due to the very flexible nature of the Python language. Some classicss are data.sort # no-op data = data.sort() # bye-bye data result = result.upper # probably not what you expect if answer.isupper: # always true ("but I entered a lowercase answer") This semester, I ran across a new one that took me quite some time to figure out what was happening. This started with a habit that too many students have of wanting to compare boolean values to True/False literals, rather than just using the boolean as a condition. That is, students seem drawn to the syntax if answer.isupper() == True: rather than the preferred if answer.isupper(): These complaints are more of style than substance, as the two versions are logically equivalent. But then a student came to me with code that wasn't behaving. The syntax they used was something akin to if x > y == True: however the condition was not being triggered, even when we verified that x was indeed greater than y. You can try this out with explicit values as follows. >>> if 5 > 4 == True: ... print "Good" >>> You will find that the body is not executed. More directly, you can look at the conditional value directly as >>> 5 > 4 True >>> 5 > 4 == True False This baffled me for an hour before finally seeing what was happening. I'll leave this as a puzzle for readers (many of whom I'm sure will be quicker than I was to see the solution). For those who give up, I offer the following link as a spoiler. http://docs.python.org/reference/expressions.html#comparisons With regard, Michael +----------------------------------------------- | Michael H. Goldwasser, Ph.D. | Associate Professor | Director of Computer Science | Dept. Mathematics and Computer Science | Saint Louis University | 220 North Grand Blvd. | St. Louis, MO 63103-2007 | | Office: Ritter Hall 108 | Email: goldwamh at slu.edu | URL: http://cs.slu.edu/~goldwasser | Phone: (314) 977-7039 | Fax: (314) 977-1452 From christian.mascher at gmx.de Tue Mar 29 17:12:46 2011 From: christian.mascher at gmx.de (Christian Mascher) Date: Tue, 29 Mar 2011 17:12:46 +0200 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: <19857.26858.803608.154614@euclid.local> References: <19857.26858.803608.154614@euclid.local> Message-ID: <4D91F6EE.9030907@gmx.de> Hi, I really like it that python allows me to write if 10 < x <= b: ... impossible in many other languages. But all things come at a cost: > > if x > y == True: > I think this is a real gotcha, because it might get you, because you _know too much_: >>> if 4: print True True >>> So all things different from 0, '', ... are considered True by python. But..... spoiler ahead ;-) >>> 4==True False >>> Cheers Christian From john.zelle at wartburg.edu Tue Mar 29 17:55:23 2011 From: john.zelle at wartburg.edu (John Zelle) Date: Tue, 29 Mar 2011 15:55:23 +0000 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: <4D91F6EE.9030907@gmx.de> References: <19857.26858.803608.154614@euclid.local>, <4D91F6EE.9030907@gmx.de> Message-ID: Hi, I agree that the behavior of booleans in Python can sometimes lead to subtle errors, but I think it's important to stress to students that writing things like: if x>y == True: is _really_ bad style. After pointing that out, I start taking points away for doing this. Code like this shows that the writer really does not understand Boolean types and their use. Expressions like this can cause subtle errors in just about any language, even those that are statically typed to prevent this sort of confusion. In Java, (x>y==true) is not a valid expression, so it won't compile. But consider this loop that seems to use done as a boolean flag:: boolean done = false; while(done = false){ // do some stuff here } The loop body will never execute. This sort of error in a strongly typed language is often very hard to spot, since we assume the compiler should catch it. If the condition is simply written as: while(!done){ then you can't go wrong. My point is that while I agree this is a "gotcha" in Python, there are similar gotchas in just about all languages. The real culprit in the original example is poor coding style, not the language semantics per se. --John ________________________________________ From: edu-sig-bounces+john.zelle=wartburg.edu at python.org [edu-sig-bounces+john.zelle=wartburg.edu at python.org] on behalf of Christian Mascher [christian.mascher at gmx.de] Sent: Tuesday, March 29, 2011 10:12 AM To: edu-sig at python.org Subject: Re: [Edu-sig] Interesting "gotcha" Hi, I really like it that python allows me to write if 10 < x <= b: ... impossible in many other languages. But all things come at a cost: > > if x > y == True: > I think this is a real gotcha, because it might get you, because you _know too much_: >>> if 4: print True True >>> So all things different from 0, '', ... are considered True by python. But..... spoiler ahead ;-) >>> 4==True False >>> Cheers Christian _______________________________________________ Edu-sig mailing list Edu-sig at python.org http://mail.python.org/mailman/listinfo/edu-sig From kirby.urner at gmail.com Tue Mar 29 18:12:50 2011 From: kirby.urner at gmail.com (kirby urner) Date: Tue, 29 Mar 2011 09:12:50 -0700 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: <19857.26858.803608.154614@euclid.local> References: <19857.26858.803608.154614@euclid.local> Message-ID: On Mon, Mar 28, 2011 at 10:06 PM, Michael H. Goldwasser wrote: > > To start a new thread, I'm always trying to keep a list of some common > "gotchas" that beginning students run across when using Python, or > things that teachers should keep in mind when teaching with the > language. Sincere applause -- exactly the kind of thread edu-sig should include in the weave. This mystr.isupper( ) == True: stuff is quite common. One also gets veterans of other languages wanting to use while instead for for loops: cnt = 0 while cnt < len(mylist): theword = mylist[cnt] of theword.isupper( ) == True: is_upper.append(theword) cnt += 1 instead of is_upper = [ theword for theword in mylist if theword.isupper() ] I was at one of David Goodger's talks which was all about getting more idiomatic. Knowing the default behavior of dicts means you know you can say for key in thedict: instead of for key in thedict.keys(): Sometimes I'll think a student is using an idiom that looks odd and so isn't "Pythonic" (as if I were the only judge). Like: mydict.update({key:value}) instead of mydict[key] = value but then I'll do a search and see enough authors using the idiom to update my own ideas of what's idiomatic. Teachers have a privileged position, getting to see the same solutions over and over but in slightly (or greatly) different styles. edu-sig makes a useful repository for those wishing to share from this perspective. Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From carl at free.org.nz Wed Mar 30 01:09:24 2011 From: carl at free.org.nz (Carl Cerecke) Date: Wed, 30 Mar 2011 12:09:24 +1300 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: <19857.26858.803608.154614@euclid.local> References: <19857.26858.803608.154614@euclid.local> Message-ID: My experience of confusing boolean expressions was the code: >>> 1 == 2 in [2, False] False which, when parenthesised the two possible ways >>> (1 == 2) in [2, False] True >>> 1 == (2 in [2, False]) True results in sensible values (although the second one's sensibility is debatable) I couldn't figure it out quickly either. In fact, I ended up decompiling to byte code to figure out what was going on. As far as other 'gotcha's in addition to the ones already mentioned: Calling a file the same name as a module in the standard library. Import will get the local file, not the stdlib one, which is confusing if you wanted the stdlib one. I've noticed that students will somtimes put import statements inside a function - right before they need to use whatever they imported: def area(r): import math return math.pi*r*r Cheers, Carl. On 29 March 2011 18:06, Michael H. Goldwasser wrote: > > To start a new thread, I'm always trying to keep a list of some common > "gotchas" that beginning students run across when using Python, or > things that teachers should keep in mind when teaching with the > language. I have in mind commands that do not generate runtime errors, > but are likely to lead to logical errors that are not apparent to > students, and most of these are legal due to the very flexible nature > of the Python language. Some classicss are > > data.sort # no-op > > data = data.sort() # bye-bye data > > result = result.upper # probably not what you expect > > if answer.isupper: # always true ("but I entered a lowercase > answer") > > > This semester, I ran across a new one that took me quite some time to > figure out what was happening. This started with a habit that too > many students have of wanting to compare boolean values to True/False > literals, rather than just using the boolean as a condition. That is, > students seem drawn to the syntax > > if answer.isupper() == True: > > rather than the preferred > > if answer.isupper(): > > These complaints are more of style than substance, as the two > versions are logically equivalent. But then a student came to me > with code that wasn't behaving. The syntax they used was something > akin to > > > if x > y == True: > > however the condition was not being triggered, even when we verified > that x was indeed greater than y. You can try this out with explicit > values as follows. > > >>> if 5 > 4 == True: > ... print "Good" > >>> > > You will find that the body is not executed. More directly, you can > look at the conditional value directly as > > >>> 5 > 4 > True > >>> 5 > 4 == True > False > > This baffled me for an hour before finally seeing what was happening. > I'll leave this as a puzzle for readers (many of whom I'm sure will be > quicker than I was to see the solution). For those who give up, I > offer the following link as a spoiler. > http://docs.python.org/reference/expressions.html#comparisons > > With regard, > Michael > > +----------------------------------------------- > | Michael H. Goldwasser, Ph.D. > | Associate Professor > | Director of Computer Science > | Dept. Mathematics and Computer Science > | Saint Louis University > | 220 North Grand Blvd. > | St. Louis, MO 63103-2007 > | > | Office: Ritter Hall 108 > | Email: goldwamh at slu.edu > | URL: http://cs.slu.edu/~goldwasser > | Phone: (314) 977-7039 > | Fax: (314) 977-1452 > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kurner at oreillyschool.com Wed Mar 30 19:50:28 2011 From: kurner at oreillyschool.com (Kirby Urner) Date: Wed, 30 Mar 2011 10:50:28 -0700 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: References: <19857.26858.803608.154614@euclid.local> Message-ID: What is a Python module? #========================== Common answer is "a file containing Python source code?", but I'm questioning whether that's sufficient definition. How about an importable .pyc or .pyd, with no .py in the picture. That's a module too, no? ** Import Star #==================================== When is import * a good idea? There's all this righteous moralistic hoopla that gets built up against specific idioms, to where eval( ) appears to be fighting for its very existence... Mary wants to keep her little lambda. So I'd rather phrase these in the positive, as in when IS it a good idea... e.g. to use semi-colons between statements. ** Another student question: #========================= Why does all([]) return True by default? Is this a case of half full versus half empty? ** Correcting a misconception #======================== No, docstrings do NOT have to be triple quoted. Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From echerlin at gmail.com Wed Mar 30 20:31:12 2011 From: echerlin at gmail.com (Edward Cherlin) Date: Wed, 30 Mar 2011 14:31:12 -0400 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: References: <19857.26858.803608.154614@euclid.local> Message-ID: So 'in' is a comparison "operator", is it? I am annoyed at how long it took me to verify that Python treats it as such, and I am also annoyed that it is so. http://docs.python.org/tutorial/datastructures.html 5.7. More on Conditions? The conditions used in while and if statements can contain any operators, not just comparisons. The comparison operators in and not in check whether a value occurs (does not occur) in a sequence. I never cared for the misleading a wrote: > My experience of confusing boolean expressions was the code: > >>>> 1 == 2 in [2, False] > False > > which, when parenthesised the two possible ways >>>> (1 == 2) in [2, False] > True >>>> 1 == (2 in [2, False]) > True > results in sensible values (although the second one's sensibility is > debatable) > > I couldn't figure it out quickly either. In fact, I ended up decompiling to > byte code to figure out what was going on. > > As far as other 'gotcha's in addition to the ones already mentioned: > > Calling a file the same name as a module in the standard library. Import > will get the local file, not the stdlib one, which is confusing if > you wanted the stdlib one. > > I've noticed that students will somtimes put import statements inside a > function - right before they need to use whatever they imported: > def area(r): > ? import math > ? return math.pi*r*r > > Cheers, > Carl. > > On 29 March 2011 18:06, Michael H. Goldwasser wrote: >> >> To start a new thread, I'm always trying to keep a list of some common >> "gotchas" that beginning students run across when using Python, or >> things that teachers should keep in mind when teaching with the >> language. I have in mind commands that do not generate runtime errors, >> but are likely to lead to logical errors that are not apparent to >> students, and most of these are legal due to the very flexible nature >> of the Python language. ?Some classicss are >> >> data.sort ? ? ? ? ? ? ? ? ?# no-op >> >> data = data.sort() ? ? ? ? # bye-bye data >> >> result = result.upper ? ? ?# probably not what you expect >> >> if answer.isupper: ? ? ? ? # always true ("but I entered a lowercase >> answer") >> >> >> This semester, I ran across a new one that took me quite some time to >> figure out what was happening. ?This started with a habit that too >> many students have of wanting to compare boolean values to True/False >> literals, rather than just using the boolean as a condition. ?That is, >> students seem drawn to the syntax >> >> ?if answer.isupper() == True: >> >> rather than the preferred >> >> ?if answer.isupper(): >> >> These complaints are more of style than substance, as the two >> versions are logically equivalent. ? But then a student came to me >> with code that wasn't behaving. ?The syntax they used was something >> akin to >> >> >> ?if x > y == True: >> >> however the condition was not being triggered, even when we verified >> that x was indeed greater than y. You can try this out with explicit >> values as follows. >> >> >>> if 5 > 4 == True: >> ... ? ? print "Good" >> >>> >> >> You will find that the body is not executed. ?More directly, you can >> look at the conditional value directly as >> >> >>> 5 > 4 >> True >> >>> 5 > 4 == True >> False >> >> This baffled me for an hour before finally seeing what was happening. >> I'll leave this as a puzzle for readers (many of whom I'm sure will be >> quicker than I was to see the solution). ?For those who give up, I >> offer the following link as a spoiler. >> http://docs.python.org/reference/expressions.html#comparisons >> >> With regard, >> Michael >> >> +----------------------------------------------- >> | Michael H. Goldwasser, Ph.D. >> | Associate Professor >> | Director of Computer Science >> | Dept. Mathematics and Computer Science >> | Saint Louis University >> | 220 North Grand Blvd. >> | St. Louis, MO 63103-2007 >> | >> | Office: Ritter Hall 108 >> | Email: ?goldwamh at slu.edu >> | URL: ? ?http://cs.slu.edu/~goldwasser >> | Phone: ?(314) 977-7039 >> | Fax: ? ?(314) 977-1452 >> >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Wed Mar 30 20:57:07 2011 From: echerlin at gmail.com (Edward Cherlin) Date: Wed, 30 Mar 2011 14:57:07 -0400 Subject: [Edu-sig] Too simple (was Re: Interesting "gotcha") Message-ID: Einstein probably did not say, "Everything should be made as simple as possible, but _no simpler_." However, somebody did, and somebody was right. One of the biggest problems in teaching programming is the constant pretense that we are not doing complicated mathematics, and the resulting attempt to hide the math. There is a lovely little book called Mathematics Made Difficult, whose premise is that refusing to tackle topics of modest complexity makes understanding far more difficult. With examples, of course. I have a similar complaint about freshman college physics courses that attempt to get by with no calculus. One of my favorite matth examples is how the use of elementary differential equations and Taylor series simplifies the definition of trigonometry. Define the exponential function by the equation y' = y which says that the growth rate of the function is proportional to its current value. Bring in examples from compound interest, biological growth, inflationary cosmology,... The function we are looking for is exp(x) = sum_0^\infty (x^n)/n! or any multiple of it. If you know that d(x^n)/dx is nx^(n-1), then you can see that the derivative of the power series for exp is itself. Now solve y' = -y (negative of exp) y'' = y (hyperbolic sinh and cosh functions) y'' = -y (sin and cos functions) in the same way, and look at the relations among their power series. Now derive e^(i\pi)+1=0 from e^(i\theta) = cos \theta + i sin \theta, which follows directly from the power series above, and then switch to linear algebra to get the sum, difference, and other formulae, and geometry to get the solutions of triangles. If anybody has difficulty with any of this I can point you to textbooks using these methods. If you would like a bit more of a challenge, we can do this all over again in elliptic and hyperbolic geometry, where we don't have similar triangles. ^_^ On Wed, Mar 30, 2011 at 13:50, Kirby Urner wrote: > > What is a Python module??#========================== > Common answer is "a file containing Python source code?", > but I'm questioning whether that's sufficient definition. > How about an importable .pyc or .pyd, with no .py in the > picture. ?That's a module too, no? > **?Import Star #==================================== > When is > import * > a good idea? > There's all this righteous moralistic hoopla that?gets built up > against specific idioms, to where eval( )?appears to be fighting > for its very existence... ?Mary wants to keep her little lambda. > So I'd?rather phrase these in the positive, as in when IS it > a good idea... e.g. to use semi-colons between statements. > ** Another student question: ?#========================= > Why does all([]) return True by default? ?Is this a case > of half full versus half empty? > ** Correcting a misconception ?#======================== > No, docstrings do NOT have to be triple quoted. > Kirby > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Wed Mar 30 21:01:26 2011 From: echerlin at gmail.com (Edward Cherlin) Date: Wed, 30 Mar 2011 15:01:26 -0400 Subject: [Edu-sig] The Undiscoverable (was Re: Interesting "gotcha") Message-ID: I am a big fan of discovery learning, and thus down on anything that interferes with discovery. I practice what I call defensive documentation on such problems, as do some others. See for example, The C Puzzle Book, and my Sugar Labs page http://wiki.sugarlabs.org/go/The_Undiscoverable We will need comprehensive, user-friendly documentation of gotchas in Python and Smalltalk for the Sugar project, for the benefit of teachers and students alike. On Tue, Mar 29, 2011 at 19:09, Carl Cerecke wrote: > My experience of confusing boolean expressions was the code: > >>>> 1 == 2 in [2, False] > False > > which, when parenthesised the two possible ways >>>> (1 == 2) in [2, False] > True >>>> 1 == (2 in [2, False]) > True > results in sensible values (although the second one's sensibility is > debatable) > > I couldn't figure it out quickly either. In fact, I ended up decompiling to > byte code to figure out what was going on. > > As far as other 'gotcha's in addition to the ones already mentioned: > > Calling a file the same name as a module in the standard library. Import > will get the local file, not the stdlib one, which is confusing if > you wanted the stdlib one. > > I've noticed that students will somtimes put import statements inside a > function - right before they need to use whatever they imported: > def area(r): > ? import math > ? return math.pi*r*r > > Cheers, > Carl. > > On 29 March 2011 18:06, Michael H. Goldwasser wrote: >> >> To start a new thread, I'm always trying to keep a list of some common >> "gotchas" that beginning students run across when using Python, or >> things that teachers should keep in mind when teaching with the >> language. I have in mind commands that do not generate runtime errors, >> but are likely to lead to logical errors that are not apparent to >> students, and most of these are legal due to the very flexible nature >> of the Python language. ?Some classicss are >> >> data.sort ? ? ? ? ? ? ? ? ?# no-op >> >> data = data.sort() ? ? ? ? # bye-bye data >> >> result = result.upper ? ? ?# probably not what you expect >> >> if answer.isupper: ? ? ? ? # always true ("but I entered a lowercase >> answer") >> >> >> This semester, I ran across a new one that took me quite some time to >> figure out what was happening. ?This started with a habit that too >> many students have of wanting to compare boolean values to True/False >> literals, rather than just using the boolean as a condition. ?That is, >> students seem drawn to the syntax >> >> ?if answer.isupper() == True: >> >> rather than the preferred >> >> ?if answer.isupper(): >> >> These complaints are more of style than substance, as the two >> versions are logically equivalent. ? But then a student came to me >> with code that wasn't behaving. ?The syntax they used was something >> akin to >> >> >> ?if x > y == True: >> >> however the condition was not being triggered, even when we verified >> that x was indeed greater than y. You can try this out with explicit >> values as follows. >> >> >>> if 5 > 4 == True: >> ... ? ? print "Good" >> >>> >> >> You will find that the body is not executed. ?More directly, you can >> look at the conditional value directly as >> >> >>> 5 > 4 >> True >> >>> 5 > 4 == True >> False >> >> This baffled me for an hour before finally seeing what was happening. >> I'll leave this as a puzzle for readers (many of whom I'm sure will be >> quicker than I was to see the solution). ?For those who give up, I >> offer the following link as a spoiler. >> http://docs.python.org/reference/expressions.html#comparisons >> >> With regard, >> Michael >> >> +----------------------------------------------- >> | Michael H. Goldwasser, Ph.D. >> | Associate Professor >> | Director of Computer Science >> | Dept. Mathematics and Computer Science >> | Saint Louis University >> | 220 North Grand Blvd. >> | St. Louis, MO 63103-2007 >> | >> | Office: Ritter Hall 108 >> | Email: ?goldwamh at slu.edu >> | URL: ? ?http://cs.slu.edu/~goldwasser >> | Phone: ?(314) 977-7039 >> | Fax: ? ?(314) 977-1452 >> >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From kirby.urner at gmail.com Wed Mar 30 21:18:14 2011 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 30 Mar 2011 12:18:14 -0700 Subject: [Edu-sig] Interesting "gotcha" In-Reply-To: References: <19857.26858.803608.154614@euclid.local> Message-ID: On Wed, Mar 30, 2011 at 11:31 AM, Edward Cherlin wrote: > So 'in' is a comparison "operator", is it? I am annoyed at how long it > took me to verify that Python treats it as such, and I am also annoyed > that it is so. > > http://docs.python.org/tutorial/datastructures.html > 5.7. More on Conditions? > > The conditions used in while and if statements can contain any > operators, not just comparisons. > As you no doubt know, in triggers the rib __contains__ in the cosmic backbone of Python's special names list, whereas operators like ==, > and < trigger their own specially named reflexes: >>> class Foo: def __contains__(self, value): print ("Yes {} is in the bar".format(value)) return True >>> bar = Foo() >>> "Joe" in bar Yes Joe is in the bar True >>> class Average: def __lt__(self, value): print("Yes {} is better than Average".format(value)) return True >>> bar = Average() >>> "Joe's bar" > bar Yes Joe's bar is better than Average True >>> > The comparison operators in and not in check whether a value occurs > (does not occur) in a sequence. > > I never cared for the misleading a > heretic! Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Wed Mar 30 22:03:42 2011 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 30 Mar 2011 13:03:42 -0700 Subject: [Edu-sig] Too simple (was Re: Interesting "gotcha") In-Reply-To: References: Message-ID: I've always been a fan of Sesame Street, some of the earliest episodes of which you can't buy as a minor they tell me, because they show kids doing too dangerous things (like making friends with strangers and running through a junk yard, hopping on bed springs or something). TV-14? On that show, very disparate artists get a crack at sharing about the Letter A or the Number 6. Claymation. Puppets. Computer graphics. Psychedelic. Even demented. If it's a style you don't like, not to worry, as clips are short. You get to sample. That's how I like a lot of math topics to get served, so "customers" find a diet they not only can stomach, but relish and wish to have more of (like "mindless consumer but not mindless" is the marketing slogan). I'm like the math teacher who changes the text book every week, and then goes over the same topics, saying "now lets see how *these* authors handle this subject matter". Or: "lets watch another Youtube about cosine, this one starring Britney Spears, formerly of the Micky Mouse club" (kids: yaaaay). http://www.youtube.com/watch?v=EQtyJZhV2lQ (another logician featured) I'm really into polyhedrons and if none of the clips have them, within a radius of 30 minutes either direction on the recording, then I'm likely to think only idiots would watch this and tune out. But that's just me. I'll find my niche, my like minded, and bliss out, twirling that volume 5 rhombic triacontahedron long into the night, marveling at all those beautiful ratios (proportions). So my Python not surprisingly tilted towards VPython in much of my writings and slideshows (from visual import *). You'll see other themes as well. Basically it's all Geometry or Geography for me (like on mathfuture), keeps it neat and easy, Occam my barber too. Kirby Urner 4dsolutions.net/ocn/cp4e.html On Wed, Mar 30, 2011 at 11:57 AM, Edward Cherlin wrote: > Einstein probably did not say, "Everything should be made as simple as > possible, but _no simpler_." However, somebody did, and somebody was > right. One of the biggest problems in teaching programming is the > constant pretense that we are not doing complicated mathematics, and > the resulting attempt to hide the math. > > There is a lovely little book called Mathematics Made Difficult, whose > premise is that refusing to tackle topics of modest complexity makes > understanding far more difficult. With examples, of course. > > I have a similar complaint about freshman college physics courses that > attempt to get by with no calculus. > > One of my favorite matth examples is how the use of elementary > differential equations and Taylor series simplifies the definition of > trigonometry. Define the exponential function by the equation > > y' = y > > which says that the growth rate of the function is proportional to its > current value. Bring in examples from compound interest, biological > growth, inflationary cosmology,... The function we are looking for is > > exp(x) = sum_0^\infty (x^n)/n! > > or any multiple of it. If you know that d(x^n)/dx is nx^(n-1), then > you can see that the derivative of the power series for exp is itself. > > Now solve > > y' = -y (negative of exp) > y'' = y (hyperbolic sinh and cosh functions) > y'' = -y (sin and cos functions) > > in the same way, and look at the relations among their power series. > > Now derive e^(i\pi)+1=0 from e^(i\theta) = cos \theta + i sin \theta, > which follows directly from the power series above, and then switch to > linear algebra to get the sum, difference, and other formulae, and > geometry to get the solutions of triangles. > > If anybody has difficulty with any of this I can point you to > textbooks using these methods. > > If you would like a bit more of a challenge, we can do this all over > again in elliptic and hyperbolic geometry, where we don't have similar > triangles. ^_^ > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: