From gbcs1978 at hotmail.com Tue Mar 1 17:25:54 2005 From: gbcs1978 at hotmail.com (Glauco Silva) Date: Tue Mar 1 17:26:04 2005 Subject: [Idle-dev] Problem with Dictionaries Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/idle-dev/attachments/20050301/8dbcef85/attachment.htm From rodsenra at gpr.com.br Tue Mar 1 22:02:46 2005 From: rodsenra at gpr.com.br (Rodrigo Dias Arruda Senra) Date: Tue Mar 1 22:02:50 2005 Subject: [Idle-dev] Problem with Dictionaries In-Reply-To: References: Message-ID: <4224D876.2010602@gpr.com.br> Glauco Silva wrote: > > I?m with problem in Dictionaries ! Glauco, since this question is not directly related to idle but to the language Python, it should be addressed to comp.lang.python. In case you are a Portuguese speaker person (guessing from your name), you could also seek help in hte python-br mailing list. In order to not let your question withou answer... > I would like to know if the dictionary can sort with a function that i > give to then! Dictionaries do not impose any particular order to their key/value pairs. One possible idiom to achieve what you want is the following: # do not use dict as the name of your variable # because 'dict' is the name and identifier of the class dict >>> d = {} >>> d[50]="fifty" >>> d[129]="one hundred twenty nine" >>> d {129: 'one hundred twenty nine', 50: 'fifty'} # extract the keys >>> sorted_keys = d.keys() # sort inplace, this returns None >>> sorted_keys.sort() # traverse the dictionary using the sorted keys list >>> for i in sorted_keys: print d[i] fifty one hundred twenty nine >>> If you are using Python 2.4, you could also use: >>> for i in sorted(d.keys()): print d[i] best regards, Rod Senra -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.5.4 - Release Date: 2005-03-01 From dooms at info.ucl.ac.be Sun Mar 6 16:01:14 2005 From: dooms at info.ucl.ac.be (=?ISO-8859-1?Q?Gr=E9goire_Dooms?=) Date: Sun Mar 6 16:03:17 2005 Subject: [Idle-dev] IDLE freezing/hanging In-Reply-To: <87wtszm72e.fsf@hydra.bayview.thirdcreek.com> References: <20050214183109.M29323-100000@localhost.name> <421164A8.8030904@wartburg.edu> <4211C3F4.4070506@info.ucl.ac.be> <87wtszm72e.fsf@hydra.bayview.thirdcreek.com> Message-ID: <422B1B3A.4060800@info.ucl.ac.be> Kurt B. Kaiser wrote: >One thing you can try is to turn on the tracing built into IDLE's >rpc.py: > >File / Open Module : rpc > >In class RPCHandler and class RPCClient there are 'debugging' >variables. Set them to True and restart IDLE. You'll now see >extensive output in the command window. Note that this output is an >interleave of everything going on, and, as is typical of output from >several threads, may be slightly out of sequence. But there are >sequence numbers associated with each rpc call to help you decode all >that. If that isn't enough, there are some print>>sys.__stderr__ >statements in rpc.py which are commented out. You can turn them on to >get a veritable blizzard of traces :-) > > > Did that. Here is the last lines before the hang-up: #S SockThread localcall: ('CALL', ('exec', 'get_the_completion_list', ('G2', 1), {})) #S SockThread pollresponse:247:localcall:response:('OK', ([], [])) #S SockThread putmessage:247: #S SockThread pollresponse:249:myseq:None #S SockThread pollresponse:249:localcall:call: #S SockThread localcall: ('CALL', ('exec', 'get_the_calltip', ('PropertyVertex',), {})) #S SockThread pollresponse:249:localcall:response:('OK', '') #S SockThread putmessage:249: #S SockThread pollresponse:251:myseq:None #S SockThread pollresponse:251:localcall:call: #S SockThread localcall: ('CALL', ('exec', 'get_the_calltip', ('__getitem__',), {})) #S SockThread pollresponse:251:localcall:response:('OK', '') #S SockThread putmessage:251: >When IDLE freezes, I assume you mean that the GUI is unresponsive, and >that you can't restart the shell from the Shell menu. > No I mean worse than that: the windows are not repainted anymore (this means the TK thread is blocked). >If so, try >this: kill the subprocess with >'kill -KILL xxxxx'. The subprocess is the one with '8833' in its >command line (ps ax). > > >IDLE should then spawn a fresh subprocess and you should be able to >continue without losing any of your work. > > > Nope, that process (zombie) then shows up in ps as: [python2.3] >If it doesn't, that points to a problem with Tk. Does it happen while >you're typing quickly, or will it freeze while you're having lunch? > > > As I stated before, it tends to happen when typing quickly (arrow keys last time). >I must say: I've been using IDLE for years, on W98, W2K, WXP, RH6.2, >Arch Linux, and OpenBSD. I've never had IDLE freeze on me unless I >made a coding error while working on IDLE itself. Then I see a >traceback in the command window. > >I have had X crash. And even a couple of emacs hangs. These things >seem to happen once in a blue moon when I'm using Gnome on Arch (which >is pretty bleeding edge). What's your desktop/window manager? > >(I mostly use Ion, it works extremely well with IDLE because Ion uses >non-overlapping panes and each pane can contain multiple tabbed IDLE >windows which can be dragged/dropped into different panes. After you >use Ion for awhile you realize that overlapping windows are just an >awful design choice made at Xerox PARC lo those many years ago. It's >also super lightweight and stable.) > > > I'm currently using KDE (because I'm too lazy to get fvwm2 configured to my tastes), I used to use ion a lot while in programming-intensive periods of my life. >IDLE is written in pure Python. So if the 'freeze' isn't due to some >hitherto undetected GUI/subprocess interaction deadlock (which can be >resolved w/o losing work by killing the subprocess), then there is an >issue in the C code implementing Python or Tk. Hardware seems to be >ruled out because all of you are having problems on Debian Sid. > >And the way to debug that is to attach gdb to it. It won't be pretty. >The subprocess has two threads: one executing user code, and one >minding the sockets. The GUI has one thread which executes the Tk >event loop, with polling implemented using after() calls. Additional >threads are created as necessary for callbacks from the subprocess. > > > Did that before killing the subprocess. In that subprocess, there were three threads all in a select call, one of them had some tk related calls in the stack. After killing the subprocess I attached gdb to the main python process and got this out of it: (gdb) info threads 2 Thread 1092189136 (LWP 5748) 0x401375d7 in select () from /lib/tls/libc.so.6 1 Thread 1075429504 (LWP 5747) 0x400310d5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0 (gdb) thread 2 [Switching to thread 2 (Thread 1092189136 (LWP 5748))]#0 0x401375d7 in select () from /lib/tls/libc.so.6 (gdb) info stack #0 0x401375d7 in select () from /lib/tls/libc.so.6 #1 0x408a2388 in Tcl_WaitForEvent () from /usr/lib/libtcl8.4.so.0 #2 0x4002e964 in start_thread () from /lib/tls/libpthread.so.0 (gdb) thread 1 [Switching to thread 1 (Thread 1075429504 (LWP 5747))]#0 0x400310d5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0 (gdb) info stack #0 0x400310d5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0 #1 0x408a1570 in Tcl_ConditionWait () from /usr/lib/libtcl8.4.so.0 #2 0x408a2115 in Tcl_WaitForEvent () from /usr/lib/libtcl8.4.so.0 #3 0x4087e35c in Tcl_DoOneEvent () from /usr/lib/libtcl8.4.so.0 #4 0x4047de51 in init_tkinter () from /usr/lib/python2.3/lib-dynload/_tkinter.so #5 0x080fde1a in PyCFunction_Call () #6 0x080ab824 in PyEval_CallObjectWithKeywords () #7 0x080a9bde in Py_MakePendingCalls () #8 0x080aa76c in PyEval_EvalCodeEx () #9 0x080ab8d9 in PyEval_CallObjectWithKeywords () #10 0x080ab71c in PyEval_CallObjectWithKeywords () #11 0x080a9bde in Py_MakePendingCalls () #12 0x080ab95d in PyEval_CallObjectWithKeywords () #13 0x080ab71c in PyEval_CallObjectWithKeywords () #14 0x080a9bde in Py_MakePendingCalls () #15 0x080aa76c in PyEval_EvalCodeEx () #16 0x080acf69 in PyEval_EvalCode () #17 0x080d90db in PyRun_FileExFlags () #18 0x080d888f in PyRun_SimpleFileExFlags () #19 0x08054e95 in Py_Main () #20 0x080549eb in main () I believe this could be related to a bug in tk8.4 (8.4.7-1) I'll upgrade now to 8.4.9-1 and see if the bug disappears. I'll report again next time the bug appears. If you have any info meanwhile... Regards, -- Gr?goire Dooms From logan at mat.uni.torun.pl Mon Mar 14 14:12:24 2005 From: logan at mat.uni.torun.pl (Przemyslaw Kisicki) Date: Mon Mar 14 14:12:34 2005 Subject: [Idle-dev] problem with set(...) in tutor Message-ID: I use: -------------------------------------------------------------------------------- Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2 ... IDLE 1.0.3 -------------------------------------------------------------------------------- I was trying to write: -------------------------------------------------------------------------------- >>> basket=['apple','orange','apple','pear','orange','banana'] >>> fruits=set(basket) -------------------------------------------------------------------------------- and I get: -------------------------------------------------------------------------------- Traceback (most recent call last): File "", line 1, in -toplevel- fruits=set(basket) NameError: name 'set' is not defined >>> -------------------------------------------------------------------------------- What's wrong? How to use sets? Logan From dblank at brynmawr.edu Mon Mar 14 15:13:15 2005 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Mon Mar 14 15:13:35 2005 Subject: [Idle-dev] problem with set(...) in tutor In-Reply-To: References: Message-ID: <42359BFB.5010606@brynmawr.edu> Logan, I believe you need Python 2.4 which added the "set" function. -Doug Przemyslaw Kisicki wrote: > I use: > -------------------------------------------------------------------------------- > Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha > 3.4.1-3mdk)] on linux2 ... IDLE 1.0.3 > -------------------------------------------------------------------------------- > I was trying to write: > -------------------------------------------------------------------------------- > >>>>basket=['apple','orange','apple','pear','orange','banana'] >>>>fruits=set(basket) > > -------------------------------------------------------------------------------- > and I get: > -------------------------------------------------------------------------------- > Traceback (most recent call last): File "", line 1, in > -toplevel- fruits=set(basket) NameError: name 'set' is not defined > > -------------------------------------------------------------------------------- > What's wrong? How to use sets? > > Logan > _______________________________________________ > IDLE-dev mailing list > IDLE-dev@python.org > http://mail.python.org/mailman/listinfo/idle-dev > > -- Douglas S. Blank, Assistant Professor dblank@brynmawr.edu, (610)526-6501 Bryn Mawr College, Computer Science Program 101 North Merion Ave, Park Science Bld. Bryn Mawr, PA 19010 dangermouse.brynmawr.edu From john.zelle at wartburg.edu Mon Mar 14 15:41:22 2005 From: john.zelle at wartburg.edu (John Zelle) Date: Mon Mar 14 15:42:30 2005 Subject: [Idle-dev] problem with set(...) in tutor In-Reply-To: <42359BFB.5010606@brynmawr.edu> References: <42359BFB.5010606@brynmawr.edu> Message-ID: <4235A292.3030809@wartburg.edu> Sets are also available as a moddule in python 2.3. This code would work if you first import: from sets import Set as set Douglas S. Blank wrote: > Logan, > > I believe you need Python 2.4 which added the "set" function. > > -Doug > > Przemyslaw Kisicki wrote: > >> I use: >> -------------------------------------------------------------------------------- >> >> Python 2.3.4 (#2, Aug 19 2004, 15:49:40) [GCC 3.4.1 (Mandrakelinux (Alpha >> 3.4.1-3mdk)] on linux2 ... IDLE 1.0.3 >> -------------------------------------------------------------------------------- >> >> I was trying to write: >> -------------------------------------------------------------------------------- >> >> >>>>> basket=['apple','orange','apple','pear','orange','banana'] >>>>> fruits=set(basket) >> >> >> -------------------------------------------------------------------------------- >> >> and I get: >> -------------------------------------------------------------------------------- >> >> Traceback (most recent call last): File "", line 1, in >> -toplevel- fruits=set(basket) NameError: name 'set' is not defined >> >> -------------------------------------------------------------------------------- >> >> What's wrong? How to use sets? >> >> Logan >> _______________________________________________ >> IDLE-dev mailing list >> IDLE-dev@python.org >> http://mail.python.org/mailman/listinfo/idle-dev >> >> > > From faramarzyari at gmail.com Sun Mar 20 17:14:43 2005 From: faramarzyari at gmail.com (faramarz yari) Date: Sun Mar 20 17:14:46 2005 Subject: [Idle-dev] can i use idle in my project Message-ID: <54771df605032008143ebbdaae@mail.gmail.com> hi everybody i want to know can i treat to idle module for example dynOptionMenuWidget, like python lib. or in other words, can i use it's module in a project thank you in advanced From kbk at shore.net Sun Mar 20 19:16:35 2005 From: kbk at shore.net (Kurt B. Kaiser) Date: Sat Mar 26 03:36:37 2005 Subject: [Idle-dev] can i use idle in my project In-Reply-To: <54771df605032008143ebbdaae@mail.gmail.com> (faramarz yari's message of "Sun, 20 Mar 2005 08:14:43 -0800") References: <54771df605032008143ebbdaae@mail.gmail.com> Message-ID: <87br9enpx8.fsf@hydra.bayview.thirdcreek.com> faramarz yari writes: > i want to know can i treat to idle module for example dynOptionMenuWidget, > like python lib. > or in other words, can i use it's module in a project > thank you in advanced IDLE is part of Python and the code is under the Python license. The answer is yes. -- KBK