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/2002-November/030374.html below:

* (and **?) in assignments

[Python-Dev] Half-baked proposal: * (and **?) in assignmentsPatrick K. O'Brien pobrien@orbtech.com
Sat, 23 Nov 2002 12:29:47 -0600
On Friday 22 November 2002 08:34 pm, Gareth McCaughan wrote:
> Since
>
>     def f(a,b,*c): ...
>     f(1,2,3,4,5)
>
> does (in effect) a=1, b=2, c=(3,4,5), I suggest that
>
>     a,b,*c = 1,2,3,4,5
>
> should do a=1, b=2, c=(3,4,5) too.

Funny you should bring this up. Last Sunday I was demonstrating Python 
to some novice programmers and we were talking about tuple unpacking. 
Someone asked how you could unpack only the first couple of items from 
a tuple. I immediately decided to try the code that you suggested and 
was disappointed it didn't work (Not that I really expected it to work, 
but sometimes you surprise yourself.) Anyway, we then moved on to 
slicing, but I do like this approach that you suggest.

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------




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