Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Steven D'Aprano
Prasad, Ramit wrote: I believe that the usage of 'in ' converts it into a set (or set-like) object so probably that is the same as set(list(set())). No, certainly not. That would be terribly inefficient, since it means first iterating over blah entirely to convert it into a set, and then iter

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Steven D'Aprano
Ali Torkamani wrote: I could resolve it by defining a small function: def getValue(mydict,keys): A=[]; for i in keys: A=A+[mydict[i]] return A That will be terribly, painfully inefficient for large amounts of data. Do you understand Big O notation? The above is O(N**2), c

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Steven D'Aprano
Alan Gauld wrote: On 06/07/12 22:16, Ali Torkamani wrote: have the pdb.set_trace()'s for debugging, to see what's going on inside. So what does it show? If you aren't using it get rid of it. The less distractions there are the easier it is to debug things. I find it ironic that you are s

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Steven D'Aprano
Ali Torkamani wrote: Dear Tutors, I'm trying to write a dictionary into a csv file, in the following code FlatData is the global dictionary whose keys are datetime objects, and the values are list of dictionaries. sCommonFeatures are key's that exist in all of such 'sub'-dictionaries, and sOtherF

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Alan Gauld
On 06/07/12 22:16, Ali Torkamani wrote: Actually printing some thing after that line does not show any thing, OK, But it could be any of the lines above the print. Why are you so sure its that line? You are probably correct but I'd like to know why you are so sure? What have you done to isolat

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Prasad, Ramit
> > Also what are you using the pdb traces for? > > Do they show any output? > Actually printing some thing after that line does not show any thing, I have > the pdb.set_trace()'s for debugging, to see what's going on inside. ho would > you debug that? When debugging, I usually just add more pri

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Mark Lawrence
Please stop top posting, you have been asked at least once before, no further comments, TIA. On 06/07/2012 22:16, Ali Torkamani wrote: Actually printing some thing after that line does not show any thing, I have the pdb.set_trace()'s for debugging, to see what's going on inside. ho would you de

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
Actually printing some thing after that line does not show any thing, I have the pdb.set_trace()'s for debugging, to see what's going on inside. ho would you debug that? On Fri, Jul 6, 2012 at 3:57 PM, Alan Gauld wrote: > On 06/07/12 18:21, Ali Torkamani wrote: > >> I'm using Python 2.7. >> By st

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Alan Gauld
On 06/07/12 18:21, Ali Torkamani wrote: I'm using Python 2.7. By stuck I mean, does not pass that specific line (but no errors). How do you know that is the line it is stuck on? def WriteOneDayToCSV(sCommonFeatures,sOtherFeatures,date): FD=FlatData[date] A=['UniqeDate','Year','Month','Da

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
I'm using Python 2.7. By stuck I mean, does not pass that specific line (but no errors). Like I said FD is a list of dictionaries. and sCommonFeatures are a subset of key's that have value in all of the dictionaries. On Fri, Jul 6, 2012 at 1:04 PM, Prasad, Ramit wrote: > > > I could resolve it

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Prasad, Ramit
> > I could resolve it by defining a small function: > > > > def getValue(mydict,keys): > > A=[]; > > for i in keys: > > A=A+[mydict[i]] > > return A > > > > and then calling it: D=getValue(prog,sCommonFeatures); > > (instead of D=[prog[key1] for key1 in list(sCommonFeatures)];)

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Prasad, Ramit
Please do not top post. > > BTW I changed it to: > D=[prog[key1] for key1 in list(sCommonFeatures)] > > because sCommonFeatures is actually a set, but it still has the smae problem > On Fri, Jul 6, 2012 at 12:27 PM, Ali Torkamani wrote: > Thanks, I checked, FD is not empty, > Thanks for remind

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
I could resolve it by defining a small function: def getValue(mydict,keys): A=[]; for i in keys: A=A+[mydict[i]] return A and then calling it: D=getValue(prog,sCommonFeatures); (instead of D=[prog[key1] for key1 in list(sCommonFeatures)];) but I'm still surprised why the latt

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
BTW I changed it to: D=[prog[key1] for key1 in list(sCommonFeatures)] because sCommonFeatures is actually a set, but it still has the smae problem On Fri, Jul 6, 2012 at 12:27 PM, Ali Torkamani wrote: > Thanks, I checked, FD is not empty, > Thanks for reminding about the flush and close, but I

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
Thanks, I checked, FD is not empty, Thanks for reminding about the flush and close, but I think some thing is wrong with: D=[prog[key1] for key1 in sCommonFeatures] In the debug mode it works fine from the command line, but in the for loop it gets stuck. Ali On Fri, Jul 6, 2012 at 12:22 PM, Pra

Re: [Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Prasad, Ramit
From: Ali Torkamani > I'm trying to write a dictionary into a csv file, in the following code > FlatData is the global dictionary whose keys are datetime objects, and the > values are list of dictionaries. sCommonFeatures are key's that exist in all > of such 'sub'-dictionaries, and sOtherFeatures

[Tutor] Program gets stuck after a creating a list from dictinary items!

2012-07-06 Thread Ali Torkamani
Dear Tutors, I'm trying to write a dictionary into a csv file, in the following code FlatData is the global dictionary whose keys are datetime objects, and the values are list of dictionaries. sCommonFeatures are key's that exist in all of such 'sub'-dictionaries, and sOtherFeatures are the key's t