Re: Function to prune dictionary keys not working

2006-06-28 Thread Bruno Desthuilliers
Girish Sahani a écrit : > hi ppl, > Here is a simple function to remove those keys of a dictionary whose > values are less than some specified value. > > But it isnt working. "is not working" is the worst possible description of a problem. > def prune(d,cp): > l = [] > for rule,value in

Re: Function to prune dictionary keys not working

2006-06-28 Thread Steve Holden
Girish Sahani wrote: > hi ppl, > Here is a simple function to remove those keys of a dictionary whose > values are less than some specified value. But it isnt working. Please > help. > Besides all the good advice you've been given about not expecting string/float comparisons to be meaningful, re

Re: Function to prune dictionary keys not working

2006-06-27 Thread Serge Orlov
On 6/27/06, John Machin <[EMAIL PROTECTED]> wrote: > |>> '1.00' >= 0.5 > True > |>> '0.33' >= 0.5 > True > > Python (correctly) does very little (guesswork-based) implicit type > conversion. At the same time, Python (incorrectly :) compares incomparable objects. -- http://mail.python.org/mailman/

Re: Function to prune dictionary keys not working

2006-06-27 Thread John Machin
On 28/06/2006 12:15 PM, Girish Sahani wrote: > hi ppl, > Here is a simple function to remove those keys of a dictionary whose > values are less than some specified value. But it isnt working. Please > help. > > def prune(d,cp): > l = [] > for rule,value in d.iteritems(): > #print

Re: Function to prune dictionary keys not working

2006-06-27 Thread Terry Reedy
"Girish Sahani" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi ppl, > Here is a simple function to remove those keys of a dictionary whose > values are less than some specified value. But it isnt working. Please > help. > > def prune(d,cp): >l = [] >for rule,value in d.i