←back to thread

121 points _ZeD_ | 1 comments | | HN request time: 0.346s | source
Show context
andy99 ◴[] No.44538191[source]

  def u(**kwargs):
    return tuple(kwargs.values())
Am I missing something, is this effectively the same?

*I realize the tuple can be omitted here

replies(4): >>44538290 #>>44538355 #>>44539536 #>>44539641 #
sischoel ◴[] No.44539536[source]
Or use itemgetter:

  >>> from operator import itemgetter
  >>> dct = {'greeting': 'hello', 'thing': 'world', 'farewell': 'bye'}
  >>> thing, greeting = itemgetter("thing", "greeting")(dct)
  >>> thing
  'world'
  >>> greeting
  'hello'
replies(3): >>44539632 #>>44540387 #>>44541901 #
1. giingyui ◴[] No.44540387[source]
There are so many things like this one in the standard library that it kinda pisses me off when I discover a new one.