From: cfelling at iae.nl (Carel Fellinger)
Date: 27 Apr 1999 21:05:42 +0200
Subject: try vs. has_key()
References: <aahzFAM4oJ.M7M@netcom.com> <yWOT2.6007$8m5.9320@newsr1.twcny.rr.com> <Pine.SUN.3.95-heb-2.07.990423140345.21577A-100000@sunset.ma.huji.ac.il>
Message-ID: <7g51q6$1pt$1@vvs.superst.iae.nl>
X-UID: 1304                                                  

Hai Moshe Zadka,

sorry to react so late, but i'm a newbie to python, so it took me some time
to realise that i really don't understand what you are doing:)

In article <Pine.SUN.3.95-heb-2.07.990423140345.21577A-100000 at sunset.ma.huji.ac.il> you wrote:
> Note: 
> This article is a non-commercial advertisement for the ``get'' method
> of dictionary objects.
> Brought to you by the object None and the method .append.

> d={}
> for word in words:
> 	d[word]=d.get(word, 0)+1

> Or, for logging:
> d={}
> for word in words:
> 	first_two=word[:2]
> 	d[first_two]=d.get(first_two, []).append(word)

this is the statement where i get lost. and when i try it with python 1.5.1
it doesn't work either. As far as i understand the append function it doesn't
return anything as it is just a shorthand for an assignment which to my
knowledge even in python 1.5.2 doesn't return values. or am i missing
something here? nonetheless, it looks great, and i sure hope it works too.

-- 
groetjes, carel




