mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
random --> arbitrary (thanks Lorenzo)
This commit is contained in:
@@ -711,7 +711,7 @@ KeyError: 21</samp></pre>
|
||||
File "<stdin>", line 1, in <module>
|
||||
KeyError: 'pop from an empty set'</samp></pre>
|
||||
<ol>
|
||||
<li>The <code>pop()</code> method removes a single value from a set and returns the value. However, since sets are unordered, there is no “last” value in a set, so there is no way to control which value gets removed. It is essentially random.
|
||||
<li>The <code>pop()</code> method removes a single value from a set and returns the value. However, since sets are unordered, there is no “last” value in a set, so there is no way to control which value gets removed. It is completely arbitrary.
|
||||
<li>The <code>clear()</code> method removes <em>all</em> values from a set, leaving you with an empty set. This is equivalent to <code>a_set = set()</code>, which would create a new empty set and overwrite the previous value of the <var>a_set</var> variable.
|
||||
<li>Attempting to pop a value from an empty set will raise a <code>KeyError</code> exception.
|
||||
</ol>
|
||||
|
||||
Reference in New Issue
Block a user