[Python-ideas] clear() method for lists

Andre Engels andreengels at gmail.com
Thu Feb 11 16:11:20 CET 2010


On Thu, Feb 11, 2010 at 3:51 PM, Gerald Britton
<gerald.britton at gmail.com> wrote:

>>>> country = ("US",)
>>>> country_state = tuple(country)+("NY",)
>>>> country_state_city = tuple(country_state) + ("NY",)
>>>> country
> ('US',)
>>>> country_state
> ('US', 'NY')
>>>> country_state_city
> ('US', 'NY', 'NY')
>
> if tuple() had a copy() method, I could write:
>
> country_state = country.copy() + ("NY",)

Note that for a tuple T

tuple(T) == T

So you can already write:

country_state = country + ("NY",)

and it will already have exactly the same effect that tuple(country)
or your proposed country.copy() would have.

-- 
André Engels, andreengels at gmail.com



More information about the Python-ideas mailing list