A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-April/099481.html below:

[Python-Dev] Very Strange Argument Handling Behavior

[Python-Dev] Very Strange Argument Handling Behavior [Python-Dev] Very Strange Argument Handling BehaviorXavier Morel python-dev at masklinn.net
Sat Apr 17 12:53:34 CEST 2010
On 16 Apr 2010, at 23:31 , Guido van Rossum wrote:
> 
> +1.
> 
> Apparently dict(x, **y) is going around as "cool hack" for "call
> x.update(y) and return x". Personally I find it more despicable than
> cool.

This description doesn't make sense since `dict(x, **y)` returns not
an updated `x` but a new dictionary merging `x` and `y`.

And that's how (and why) I use it, it's simpler (and — I believe — more
readable) to write `z = dict(x, **y)` than `z = dict(x); z.update(y)`,
since Python doesn't overload addition as it does for lists:
    l3 = l1 + l2
works and is equivalent to
    l3 = list(l1); l3.extend(l2)

but there is no easy way to say that with dicts, at the moment.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4