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

26 Oct
2009
26 Oct
'09
9:50 p.m.
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@gmail.com | Brisbane, Australia
---------------------------------------------------------------
5154
Age (days ago)
5154
Last active (days ago)
0 comments
1 participants
participants (1)
-
Nick Coghlan