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/2004-March/043408.html below:

[Python-Dev] Chaining seq1.pop().extend(seq2) does give wrong result

[Python-Dev] Chaining seq1.pop().extend(seq2) does give wrong resultSjoerd Mullender sjoerd at acm.org
Tue Mar 23 10:04:34 EST 2004
Jacek Trzmiel wrote:
> Hi,
> 
> $ python
> Python 2.3.2 (#1, Dec  5 2003, 03:04:50) 
> [GCC 3.3.3 [FreeBSD] 20031106] on freebsd5
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>>stack = [[1], [2]]
>>>>fields = [3]
>>>>out = stack.pop()
>>>>out.extend(fields)
>>>>print out
> 
> [2, 3]
> 
>>>>stack = [[1], [2]]
>>>>fields = [3]
>>>>out = stack.pop().extend(fields)
>>>>print out
> 
> None
> 
> 
> Shouldn't those two give identical result?

No.  somelist.extend() changes somelist but doesn't return a value (in 
other words, it returns None, which is exactly what you're seeing).

Also, this is not really appropriate for python-dev, but rather for 
python-list, I would think.

-- 
Sjoerd Mullender <sjoerd at acm.org>

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