Tkinter and Chess problems
Dear All Recently I have been playing with Tkinter. I wrote two scripts to solve well known chess problems: eight queens and knight's tour. Both are available here: https://github.com/LalithaPrasad/PythonScripts All are welcome to download and improve them if required. Hope to rewrite them using the other GUI libraries for comparison purposes. But I think, though Tkinter is considered primitive, It is extremely easy to use. Cheers Lalitha Prasad -- http://mail.python.org/mailman/listinfo/python-list
Re: Fun and games with lambda
I would rate it as a great example of human ingenuity Lalit On Fri, Jun 17, 2011 at 9:40 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > If you've ever wondered what lambda and reduce are good for, run this one- > liner and wonder no more... > > (Be patient, it may take a few seconds to return.) > > # Python 2 version: > > print((lambda f:((lambda p:p[0]+'.'+p[1:])(str((lambda Q:2*Q[0]*Q[0]//Q > [3])((lambda F:(lambda S:f(lambda T,_:((T[0]+T[1])//2,S((T[0]*T[1])// > F),2*T[2],(T[3]-(T[2]*(((T[0]+T[1])//2)**2-(S((T[0]*T[1])//F))**2))//F)), > [0]*13,(F,(F*F)//S(2*F),2,F//2)))(lambda n:f(lambda x,_:(x-x//2+(n*F)// > (2*x)),[0]*15,n//2)))(10**(5010[:5000])))(reduce)) > > # Python 3 version: > > print((lambda f:((lambda p:p[0]+'.'+p[1:])(str((lambda Q:2*Q[0]*Q[0]//Q > [3])((lambda F:(lambda S:f(lambda T,_:((T[0]+T[1])//2,S((T[0]*T[1])// > F),2*T[2],(T[3]-(T[2]*(((T[0]+T[1])//2)**2-(S((T[0]*T[1])//F))**2))//F)), > [0]*13,(F,(F*F)//S(2*F),2,F//2)))(lambda n:f(lambda x,_:(x-x//2+(n*F)// > (2*x)),[0]*15,n//2)))(10**(5010[:5000])))(__import__ > ('functools').reduce)) > > > I can't take credit for this little beauty. It originally came from > Manuel Garcia, all I did was make it compatible with Python 3 and add > some additional, but trivial, obfuscation. > > See the original post here: > http://web.archiveorange.com/archive/v/5H3d1yQN5N15HEgOWHMx > > > > Encouraging-hatred-of-lambdas-for-fun-and-profit-ly y'rs, > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Significant figures calculation
In numerical analysis there is this concept of machine zero, which is computed like this: e=1.0 while 1.0+e > 1.0: e=e/2.0 print e The number e will give you the precision of floating point numbers. Lalitha Prasad On Sun, Jun 26, 2011 at 9:05 PM, Harold wrote: > > >I'm curious. Is there a way to get the number of significant digits > > >for a particular Decimal instance? > > > > Yes: > > > > def sigdig(x): > > "return the number of significant digits in x" > > return len(x.as_tuple()[1]) > > Great! that's exactly what I needed. > thanks Chris! > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Teaching python to non-programmers
Dear List Recently I was requested to teach python to a group of students of GIS (Geographic Information Systems). Their knowledge of programming is zero. The objective is to enable them to write plug-ins for GIS software like QGIS and ArcGIS. It would require them to learn, besides core python, PyQt, QtDesigner. So my plan is to teach them core python, PyQt, Qt Designer, in that order. A kind of "bottom up approach". But the students seem to feel that I should use "top down approach". That is, show them how to write a plug-in, then PyQt and Qt Designer and then enough of python so they can handle the above. I don't think, that is possible or a good idea. But I would like to know, if there are any other approaches. Thanks and Regards Lalitha Prasad, -- https://mail.python.org/mailman/listinfo/python-list