Python Forum
methods of a dictionary vs a sequence
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
methods of a dictionary vs a sequence
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020