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 
other language. Another problem is that the author seems unable to drop 
any material that is out of date; the pace is slowed by explanations of 
what you might need to do if using a very old version. The third edition 
is even worse is that respect. Also, being based of the author's 
training experience, is not always a good thing. I prefer a book to 
sitting in a class because I don't want to fall asleep whilst the 
instructor repeats an explanation yet again for the benefit of those at 
the back, nor wait while clever-clogs at the front asks an arcane 
question of no general interest. Learning Python is too much like 
sitting in a classroom for me.


If you already know some programming Python in a Nutshell is very useful.



good. You might also look at Hetland's "Beginning Python" or even the
"Python for Dummies" book.

Mike

--
http://mail.python.org/mailman/listinfo/python-list


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 defaultdict which I have compared to
>> counter['B'] = counter.get('B', 0) + 1
on a file with 125,000 additions default dict was significantly slower 
(only ~40seconds v ~30 secs for get) and used twice the memory.


--
djc
--
http://mail.python.org/mailman/listinfo/python-list


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 in two sorted sequences is 
efficient but a random lookup would be more convenient. A solution based 
on AVL trees seems possible.



--
djc
--
http://mail.python.org/mailman/listinfo/python-list