A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/318088.html below:

Inconsistent reaction to extend

Inconsistent reaction to extendFredrik Lundh fredrik at pythonware.com
Fri Sep 9 06:06:20 EDT 2005
Jerzy Karczmarczuk wrote:

> Gurus, before I am tempted to signal this as a bug, perhaps
> you might convince me that it should be so.

it's not a bug, and nobody should have to convince you about any-
thing; despite what you may think from reading certain slicing threads,
this mailing list is not an argument clinic.

> If I type
>
> l=range(4)
> l.extend([1,2])
>
> l  gives [0,1,2,3,1,2], what else...
>
> On the other hand, try
>
> p=range(4).extend([1,2])
>
> Then, p HAS NO VALUE (NoneType).

(footnote: None is a value in Python.  it can be used to represent "no value",
but it can also be used for other things)

> With append the behaviour is similar. I didn't try other methods, but
> I suspect that it won't improve.
>
> WHY?

because you're saving the return value of "extend", not "range", and "extend"
returns None.

if you split it up like this

    l = range(4)
    p = l.extend([1, 2])

it should be obvious that "l" and "p" doesn't necessarily contain the same thing.

</F> 




More information about the Python-list 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