Python Forum

Full Version: methods of a dictionary vs a sequence
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
both dictionary and sequence have .pop that gets a value (indexed according to the behavior/methods of the type/class) then removes it from the source.

but there is a difference.

dict.pop() also supports a default value.  seq.pop() does not.   OTOH, defaults when indexing sequences is not needed much in classic logic.  but why not have it for consistency?

also there is dict.get() (with arguments like dict.pop()) but no seq.get().  without a default argument, class.get() is just class[].  i'd like to see a 2nd optional argument of default added to seq.pop() and seq.get() with a 2nd optional argument of default added to sequences.