Re: Append a new value to dict

2008-10-23 Thread slais-www
[EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch: counter['B'] = counter.get('B', 0) + 1 If you benchmark it, you will find that using the get() method it's quite slower. Slower than if 'B' in counter: > counter['B'] += 1 > else: > counter['B'] = 1 ? It is not slower than default

Re: book recommendation for Python newbie?

2008-10-10 Thread slais-www
Mike Driscoll wrote: A lot of people recommend Lutz's "Learning Python". While I haven't read it, I have read his follow-up "Programming Python" and it was I found Learning Python good for learning, and a useful reference sometimes, but it can seem very slow paced if you already know some oth

at_most: search "dictionary" for less than or equal

2008-08-11 Thread slais-www
Before I set out to reinvent the wheel. I want a dictionary-like structure for which most lookups will be on a key that is not in the "dictionary"; in which case I want a key/value returned which is the closest key that is less than the search term. The batch solution of matching the values