Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def itemgetter(*items):
if HAS_OPERATOR:
return operator.itemgetter(*items)
else:
if len(items) == 1:
item = items[0]
def g(obj):
return obj[item]
else:
def g(obj):
return tuple(obj[item] for item in items)
return g
def itemgetter(*items):
if HAS_OPERATOR:
return operator.itemgetter(*items)
else:
if len(items) == 1:
item = items[0]
def g(obj):
return obj[item]
else:
def g(obj):
return tuple(obj[item] for item in items)
return g