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/2009-October/093386.html below:

[Python-Dev] One obvious way to do interning [Was: Retrieve an arbitrary element from a set without removing it]

[Python-Dev] One obvious way to do interning [Was: Retrieve an arbitrary element from a set without removing it] [Python-Dev] One obvious way to do interning [Was: Retrieve an arbitrary element from a set without removing it]Nick Coghlan ncoghlan at gmail.com
Mon Oct 26 22:50:56 CET 2009
Terry Reedy wrote:
> Alexander Belopolsky wrote:
>> Terry Reedy wrote:
>>> I had exactly the same idea, but did not post because it violates the
>>> general rule that mutators return None.
>>
>> Is there such a rule?  What about set/dict pop?
> 
> The rule perhaps should be restated as 'Collection mutators return None
> or possible an item but not the collection.'

And to clarify the rationale for that guideline: it is to make it clear
that the mutator is changing the container in place and *not* creating a
new container object.

myset.pop()     # No new container, returns popped object
mylist.sort()   # No new container, returns None
sorted(mylist)  # New container, so return it
mystr.lower()   # Creates new string, so return it

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
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