Duncan Booth writes:
> The suggested alternative:
>
>value = data.get(key, None)
>
> also has two dictionary lookups:...
dg = data.get
...
(inside loop):
value = dg(key,None)
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 28 Jun 2009 02:57:50 -0700, Carl Banks wrote:
> So it's not valid in general to equate the two lookups. Unless you know
> that your dict keys are going to be really fast like interned strings it
> makes sense to minimize dict lookups.
Or to stop making assumptions about what's fast and w
On Jun 27, 4:40 am, Duncan Booth wrote:
> Thomas Lehmann wrote:
> > Hi!
>
> > In C++, programming STL you will use the insert method which always
> > provides a position and a flag which indicates whether the position
> > results from a new insertion or an exisiting element. Idea is to have
> > o
Steven D'Aprano writes:
> On Sat, 27 Jun 2009 09:41:13 -0700, Rachel P wrote:
> [...]
> > Raymond
>
> Raymond, does Rachel know you're using her gmail account?
It's a good thing names are being used here, rather than just initials.
--
\“No one ever went broke underestimating the
On Sat, 27 Jun 2009 09:41:13 -0700, Rachel P wrote:
[...]
> Raymond
Raymond, does Rachel know you're using her gmail account?
*wink*
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Lehmann wrote:
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
if data.has_key(key):
value = data[key]
But
[Thomas Lehmann]
> In C++, programming STL you will use the insert method which always
> provides a position and a flag which indicates whether the position
> results from a new insertion or an exisiting element. Idea is to have
> one search only.
>
>
> if data.has_key(key):
> value = data[key
Thomas Lehmann wrote:
> Hi!
>
> In C++, programming STL you will use the insert method which always
> provides a position and a flag which indicates whether the position
> results from a new insertion or an exisiting element. Idea is to have
> one search only.
>
>
> if data.has_key(key):
>
Thomas Lehmann writes:
>
> if data.has_key(key):
>value = data[key]
>
>
> But this does mean (does it?) that the dictionary is searched two
> times! If so, can somebody show me how to do this in one step?
value = data.get(key, None)
sets value to None if the key is not in the dictiona
On Sat, Jun 27, 2009 at 2:47 AM, Thomas
Lehmann wrote:
> Hi!
>
> In C++, programming STL you will use the insert method which always
> provides a position and a flag which indicates whether the position
> results from a new insertion or an exisiting element. Idea is to have
> one search only.
>
>
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
if data.has_key(key):
value = data[key]
But this does mean (doe
11 matches
Mail list logo