python crashes in Komodo
Using the Komodo IDE under XP I often get python.exe has encountered a problem and needs to close. Running python direct on the same app gives a list index out of bounds error. Any ideas how to get Komodo to give the proper error? -- http://mail.python.org/mailman/listinfo/python-list
Re: python crashes in Komodo
Komodo ver 3.5.2, build 227162, platform win32-ix86. XP SP 2 Python 2.4.2 I did not think to enter the bug as it is so basic - list index out of bounds. When I run python at a dos prompt python handles the error properly. In Komodo, a simple case like this is no problem. x = [1,2,3] print x[4] I'll see if I can get the time to create an app that shows the problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing a method indirectly
Thanks - that worked! Thanks to the other replies also. -- http://mail.python.org/mailman/listinfo/python-list
Passing a method indirectly
I'm trying to write a function that takes an arbitrary object and method. The function applies the method to the object (and some other stuff). I get error Test instance has no attribute 'method' How can I make this work? def ObjApply (object,method): object.method () class Test: def test1 (self): print Hello def test2 (self): ObjApply (self,self.test1) ta = Test () ta.test2 () -- http://mail.python.org/mailman/listinfo/python-list
Shortest prime number program
I figured someone out there must have written a minimal code size prime number generator. I did not find one after a bit of searching around. For primes up to 100 the best I could do was 70 characters (including spaces): r=range(2,99) m=[x*y for x in r for y in r] [x for x in r if not x in m] -- http://mail.python.org/mailman/listinfo/python-list
Re: Shortest prime number program
At 58, very nice :-) Building on yours we get 57: r=range(2,99) [x for x in r if sum([x%d==0 for d in r])2] -- http://mail.python.org/mailman/listinfo/python-list
Re: Shortest prime number program
You can save two bytes with 56 - nice catch. 55: r=range(2,99) [x for x in r if sum(x%d1 for d in r)2] -- http://mail.python.org/mailman/listinfo/python-list
Re: Shortest prime number program
[2]+[x for x in range(1,99) if 2**x%x==2] 42 - brilliant! 41: [2]+[x for x in range(1,99)if 2**x%x==2] ... although it appears Christoph is right that it's not scalable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Shortest prime number program
42 Make that 41 and 40. -- http://mail.python.org/mailman/listinfo/python-list
Server side newbie
I have a simple python desktop app with several edit controls and a couple of buttons. It just does some math. What's the simplest way to make it a server-side app so visitors to my site can run the app via their browser? -- http://mail.python.org/mailman/listinfo/python-list
textvariable help
I must be missing something basic. Can anyone explain why 'A' does not show on the entry widget? import Tkinter root = Tkinter.Tk() class Col: Rows = [0] def __init__(self): Frame = Tkinter.Frame(root); Frame.pack (side='left') self.Rows[0] = Tkinter.StringVar(); Tkinter.Entry(Frame,textvariable=self.Rows[0]).pack (); X = Col() # X.Rows[0].set ('A') # 'A' displays in Entry this way Y = Col() X.Rows[0].set ('A') # Why not also this way? Y.Rows[0].set ('B') root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
Thanks for the quick reply. With your reply and another tutorial I get it now. I needed self.Rows = ... in the constructor. I find myself wasting a lot of time with poor python docs. Whatever time Python is supposed to save I'm losing so far in looking up things. I suppose that will change as I get past the learning curve. Are you aware of any good docs on python that make it easy to find things? -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
None - it was a false impression I got somehow. -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
Thanks - actually I have some of those books on the way from amazon. The first couple of days with a new language are always the hardest! -- http://mail.python.org/mailman/listinfo/python-list