question_id
stringlengths
7
12
nl
stringlengths
4
200
cmd
stringlengths
2
232
oracle_man
sequence
canonical_cmd
stringlengths
2
228
cmd_name
stringclasses
1 value
35707224-41
sum the length of lists in list `x` that are more than 1 item in length
sum(len(y) for y in x if len(y) > 1)
[ "python.library.functions#len", "python.library.functions#sum" ]
sum(len(y) for y in VAR_STR if len(y) > 1)
conala
1749466-50
Normalize line ends in a string 'mixed'
mixed.replace('\r\n', '\n').replace('\r', '\n')
[ "python.library.stdtypes#str.replace" ]
VAR_STR.replace('\r\n', '\n').replace('\r', '\n')
conala
4695143-39
replace each occurrence of the pattern '(http://\\S+|\\S*[^\\w\\s]\\S*)' within `a` with ''
re.sub('(http://\\S+|\\S*[^\\w\\s]\\S*)', '', a)
[ "python.library.re#re.sub" ]
re.sub('VAR_STR', 'VAR_STR', VAR_STR)
conala
9323749-54
check if dictionary `subset` is a subset of dictionary `superset`
all(item in list(superset.items()) for item in list(subset.items()))
[ "python.library.functions#list", "python.library.functions#all", "python.library.stdtypes#dict.items" ]
all(item in list(VAR_STR.items()) for item in list(VAR_STR.items()))
conala
24525111-6
Save plot `plt` as svg file 'test.svg'
plt.savefig('test.svg')
[ "matplotlib.figure_api#matplotlib.figure.Figure.savefig" ]
VAR_STR.savefig('VAR_STR')
conala
18131741-100
check if elements in list `my_list` are coherent in order
return my_list == list(range(my_list[0], my_list[-1] + 1))
[ "python.library.functions#range", "python.library.functions#list" ]
return VAR_STR == list(range(VAR_STR[0], VAR_STR[-1] + 1))
conala
9880173-43
decode encodeuricomponent in GAE
urllib.parse.unquote(h.path.encode('utf-8')).decode('utf-8')
[ "python.library.urllib.parse#urllib.parse.unquote", "python.library.stdtypes#str.encode", "python.library.stdtypes#bytearray.decode" ]
urllib.parse.unquote(h.path.encode('utf-8')).decode('utf-8')
conala
29218750-37
remove items from dictionary `myDict` if the item's value `val` is equal to 42
myDict = {key: val for key, val in list(myDict.items()) if val != 42}
[ "python.library.functions#list", "python.library.stdtypes#dict.items" ]
VAR_STR = {key: VAR_STR for key, VAR_STR in list(VAR_STR.items()) if VAR_STR != 42}
conala
29218750-94
Remove all items from a dictionary `myDict` whose values are `42`
{key: val for key, val in list(myDict.items()) if val != 42}
[ "python.library.functions#list", "python.library.stdtypes#dict.items" ]
{key: val for key, val in list(VAR_STR.items()) if val != 42}
conala
11833266-99
read the first line of a string `my_string`
my_string.splitlines()[0]
[ "python.library.stdtypes#str.splitlines" ]
VAR_STR.splitlines()[0]
conala
11833266-33
How do I read the first line of a string?
my_string.split('\n', 1)[0]
[ "python.library.stdtypes#str.split" ]
my_string.split('\n', 1)[0]
conala
8386675-18
extracting column `1` and `9` from array `data`
data[:, ([1, 9])]
[]
VAR_STR[:, ([1, 9])]
conala
30650254-82
serve a static html page 'your_template.html' at the root of a django project
url('^$', TemplateView.as_view(template_name='your_template.html'))
[ "flask.api.index#flask.views.View.as_view", "django.ref.request-response#django.http.HttpResponseRedirect.url" ]
url('^$', TemplateView.as_view(template_name='VAR_STR'))
conala
5796238-23
return the conversion of decimal `d` to hex without the '0x' prefix
hex(d).split('x')[1]
[ "python.library.functions#hex", "python.library.stdtypes#str.split" ]
hex(VAR_STR).split('x')[1]
conala
17407691-98
Get multiple matched strings using regex pattern `(?:review: )?(http://url.com/(\\d+))\\s?`
pattern = re.compile('(?:review: )?(http://url.com/(\\d+))\\s?', re.IGNORECASE)
[ "python.library.re#re.compile" ]
pattern = re.compile('VAR_STR', re.IGNORECASE)
conala
9560207-5
get count of values in numpy array `a` that are between values `25` and `100`
((25 < a) & (a < 100)).sum()
[ "python.library.functions#sum" ]
((25 < VAR_STR) & (VAR_STR < 100)).sum()
conala
4628618-90
replace only first occurence of string `TEST` from a string `longlongTESTstringTEST`
'longlongTESTstringTEST'.replace('TEST', '?', 1)
[ "python.library.stdtypes#str.replace" ]
"""VAR_STR""".replace('VAR_STR', '?', 1)
conala
21618351-81
format current date to pattern '{%Y-%m-%d %H:%M:%S}'
time.strftime('{%Y-%m-%d %H:%M:%S}')
[ "python.library.time#time.strftime" ]
time.strftime('VAR_STR')
conala
13462365-6
count the number of pairs in dictionary `d` whose value equal to `chosen_value`
sum(x == chosen_value for x in list(d.values()))
[ "python.library.functions#sum", "python.library.functions#list", "python.library.stdtypes#dict.values" ]
sum(x == VAR_STR for x in list(VAR_STR.values()))
conala
13462365-75
count the number of values in `d` dictionary that are predicate to function `some_condition`
sum(1 for x in list(d.values()) if some_condition(x))
[ "python.library.functions#sum", "python.library.functions#list", "python.library.stdtypes#dict.values" ]
sum(1 for x in list(VAR_STR.values()) if VAR_STR(x))
conala
17057544-4
Get absolute folder path and filename for file `existGDBPath `
os.path.split(os.path.abspath(existGDBPath))
[ "python.library.os.path#os.path.abspath", "python.library.os.path#os.path.split" ]
os.path.split(os.path.abspath(VAR_STR))
conala
17057544-2
extract folder path from file path
os.path.dirname(os.path.abspath(existGDBPath))
[ "python.library.os.path#os.path.dirname", "python.library.os.path#os.path.abspath" ]
os.path.dirname(os.path.abspath(existGDBPath))
conala
41923906-34
align values in array `b` to the order of corresponding values in array `a`
a[np.in1d(a, b)]
[ "numpy.reference.generated.numpy.in1d" ]
VAR_STR[np.in1d(VAR_STR, VAR_STR)]
conala
20375561-45
Join pandas data frame `frame_1` and `frame_2` with left join by `county_ID` and right join by `countyid`
pd.merge(frame_1, frame_2, left_on='county_ID', right_on='countyid')
[ "pandas.reference.api.pandas.merge" ]
pd.merge(VAR_STR, VAR_STR, left_on='VAR_STR', right_on='VAR_STR')
conala
983855-47
Python JSON encoding
json.dumps({'apple': 'cat', 'banana': 'dog', 'pear': 'fish'})
[ "python.library.json#json.dumps" ]
json.dumps({'apple': 'cat', 'banana': 'dog', 'pear': 'fish'})
conala
9932549-12
get key-value pairs in dictionary `my_dictionary` for all keys in list `my_list` in the order they appear in `my_list`
dict(zip(my_list, map(my_dictionary.get, my_list)))
[ "python.library.functions#zip", "python.library.functions#map", "python.library.stdtypes#dict" ]
dict(zip(VAR_STR, map(VAR_STR.get, VAR_STR)))
conala
34148637-13
sort json `ips_data` by a key 'data_two'
sorted_list_of_keyvalues = sorted(list(ips_data.items()), key=item[1]['data_two'])
[ "python.library.functions#sorted", "python.library.functions#list", "python.library.stdtypes#dict.items" ]
sorted_list_of_keyvalues = sorted(list(VAR_STR.items()), key=item[1]['VAR_STR'])
conala
3845423-4
remove empty strings from list `str_list`
str_list = list([_f for _f in str_list if _f])
[ "python.library.functions#list" ]
VAR_STR = list([_f for _f in VAR_STR if _f])
conala
20206615-96
do a `left` merge of dataframes `x` and `y` on the column `state` and sort by `index`
x.reset_index().merge(y, how='left', on='state', sort=False).sort('index')
[ "pandas.reference.api.pandas.merge", "pandas.reference.api.pandas.dataframe.reset_index" ]
VAR_STR.reset_index().merge(VAR_STR, how='VAR_STR', on='VAR_STR', sort=False).sort( 'VAR_STR')
conala
32458541-85
Confirm urls in Django properly
url('^$', include('sms.urls')),
[ "django.ref.urls#django.urls.include", "django.ref.request-response#django.http.HttpResponseRedirect.url" ]
url('^$', include('sms.urls')),
conala
32458541-57
Configure url in django properly
url('^', include('sms.urls')),
[ "django.ref.urls#django.urls.include", "django.ref.request-response#django.http.HttpResponseRedirect.url" ]
url('^', include('sms.urls')),
conala
39804375-37
sort a list of dictionary `persons` according to the key `['passport']['birth_info']['date']`
sorted(persons, key=lambda x: x['passport']['birth_info']['date'])
[ "python.library.functions#sorted" ]
sorted(VAR_STR, key=lambda x: x[VAR_STR])
conala
10941229-55
flatten list of tuples `a`
list(chain.from_iterable(a))
[ "python.library.functions#list", "python.library.itertools#itertools.chain.from_iterable" ]
list(chain.from_iterable(VAR_STR))
conala
20668060-74
change the background colour of the button `pushbutton` to red
self.pushButton.setStyleSheet('background-color: red')
[]
self.pushButton.setStyleSheet('background-color: red')
conala
19617355-91
Change log level dynamically to 'DEBUG' without restarting the application
logging.getLogger().setLevel(logging.DEBUG)
[ "python.library.logging#logging.getLogger", "python.library.logging#logging.Handler.setLevel" ]
logging.getLogger().setLevel(logging.VAR_STR)
conala
29100599-74
resample series `s` into 3 months bins and sum each bin
s.resample('3M', how='sum')
[ "sklearn.modules.generated.sklearn.utils.resample#sklearn.utils.resample" ]
VAR_STR.resample('3M', how='sum')
conala
15282189-27
Set colorbar range from `0` to `15` for pyplot object `quadmesh` in matplotlib
quadmesh.set_clim(vmin=0, vmax=15)
[ "matplotlib.collections_api#matplotlib.collections.QuadMesh.set_clim" ]
VAR_STR.set_clim(vmin=0, vmax=15)
conala
2806611-99
check if all boolean values in a python dictionary `dict` are true
all(dict.values())
[ "python.library.stdtypes#dict.values", "python.library.functions#all" ]
all(VAR_STR.values())
conala
1456617-78
return a random word from a word list 'words'
print(random.choice(words))
[ "python.library.random#random.choice" ]
print(random.choice(VAR_STR))
conala
6275762-86
escaping quotes in string
replace('"', '\\"')
[ "python.library.stdtypes#str.replace" ]
replace('"', '\\"')
conala
4703390-2
extract floating number from string 'Current Level: 13.4 db.'
re.findall('\\d+\\.\\d+', 'Current Level: 13.4 db.')
[ "python.library.re#re.findall" ]
re.findall('\\d+\\.\\d+', 'VAR_STR')
conala
4703390-17
extract floating point numbers from a string 'Current Level: -13.2 db or 14.2 or 3'
re.findall('[-+]?\\d*\\.\\d+|\\d+', 'Current Level: -13.2 db or 14.2 or 3')
[ "python.library.re#re.findall" ]
re.findall('[-+]?\\d*\\.\\d+|\\d+', 'VAR_STR')
conala
4998629-17
split string `str` with delimiter '; ' or delimiter ', '
re.split('; |, ', str)
[ "python.library.re#re.split" ]
re.split('; |, ', VAR_STR)
conala
3704731-64
replace non-ascii chars from a unicode string u'm\xfasica'
unicodedata.normalize('NFKD', 'm\xfasica').encode('ascii', 'ignore')
[ "python.library.unicodedata#unicodedata.normalize", "python.library.stdtypes#str.encode" ]
unicodedata.normalize('NFKD', 'VAR_STR').encode('ascii', 'ignore')
conala
33147992-55
convert a string `a` of letters embedded in squared brackets into embedded lists
[i.split() for i in re.findall('\\[([^\\[\\]]+)\\]', a)]
[ "python.library.re#re.findall", "python.library.re#re.split" ]
[i.split() for i in re.findall('\\[([^\\[\\]]+)\\]', VAR_STR)]
conala
40173569-0
Parse DateTime object `datetimevariable` using format '%Y-%m-%d'
datetimevariable.strftime('%Y-%m-%d')
[ "python.library.time#time.strftime" ]
VAR_STR.strftime('VAR_STR')
conala
3989016-64
get index of the first biggest element in list `a`
a.index(max(a))
[ "python.library.functions#max" ]
VAR_STR.index(max(VAR_STR))
conala
22086116-75
create dataframe `males` containing data of dataframe `df` where column `Gender` is equal to 'Male' and column `Year` is equal to 2014
males = df[(df[Gender] == 'Male') & (df[Year] == 2014)]
[]
VAR_STR = VAR_STR[(VAR_STR[VAR_STR] == 'VAR_STR') & (VAR_STR[VAR_STR] == 2014)]
conala
663171-65
get a new string from the 3rd character to the end of the string `x`
x[2:]
[]
VAR_STR[2:]
conala
663171-26
get a new string including the first two characters of string `x`
x[:2]
[]
VAR_STR[:2]
conala
663171-13
get a new string including all but the last character of string `x`
x[:(-2)]
[]
VAR_STR[:-2]
conala
663171-83
get a new string including the last two characters of string `x`
x[(-2):]
[]
VAR_STR[-2:]
conala
663171-42
get a new string with the 3rd to the second-to-last characters of string `x`
x[2:(-2)]
[]
VAR_STR[2:-2]
conala
663171-55
reverse a string `some_string`
some_string[::(-1)]
[]
VAR_STR[::-1]
conala
663171-82
select alternate characters of "H-e-l-l-o- -W-o-r-l-d"
'H-e-l-l-o- -W-o-r-l-d'[::2]
[]
"""VAR_STR"""[::2]
conala
663171-31
select a substring of `s` beginning at `beginning` of length `LENGTH`
s = s[beginning:(beginning + LENGTH)]
[]
VAR_STR = VAR_STR[VAR_STR:VAR_STR + VAR_STR]
conala
9089043-68
Get a list of items in the list `container` with attribute equal to `value`
items = [item for item in container if item.attribute == value]
[]
items = [item for item in VAR_STR if item.attribute == VAR_STR]
conala
32191029-91
Get the indices in array `b` of each element appearing in array `a`
np.in1d(b, a).nonzero()[0]
[ "numpy.reference.generated.numpy.in1d", "numpy.reference.generated.numpy.nonzero" ]
np.in1d(VAR_STR, VAR_STR).nonzero()[0]
conala
4174941-83
sort a list of lists `L` by index 2 of the inner list
sorted(L, key=itemgetter(2))
[ "python.library.functions#sorted", "python.library.operator#operator.itemgetter" ]
sorted(VAR_STR, key=itemgetter(2))
conala
4174941-52
sort a list of lists `l` by index 2 of the inner list
l.sort(key=(lambda x: x[2]))
[ "python.library.stdtypes#list.sort" ]
VAR_STR.sort(key=lambda x: x[2])
conala
4174941-58
sort list `l` by index 2 of the item
sorted(l, key=(lambda x: x[2]))
[ "python.library.functions#sorted" ]
sorted(VAR_STR, key=lambda x: x[2])
conala
4174941-60
sort a list of lists `list_to_sort` by indices 2,0,1 of the inner list
sorted_list = sorted(list_to_sort, key=itemgetter(2, 0, 1))
[ "python.library.functions#sorted", "python.library.operator#operator.itemgetter" ]
sorted_list = sorted(VAR_STR, key=itemgetter(2, 0, 1))
conala
40707158-98
Change data type of data in column 'grade' of dataframe `data_df` into float and then to int
data_df['grade'] = data_df['grade'].astype(float).astype(int)
[ "pandas.reference.api.pandas.dataframe.astype" ]
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].astype(float).astype(int)
conala
15985339-6
get current url in selenium webdriver `browser`
print(browser.current_url)
[]
print(VAR_STR.current_url)
conala
15411107-8
Delete an item with key "key" from `mydict`
mydict.pop('key', None)
[ "python.library.stdtypes#dict.pop" ]
VAR_STR.pop('VAR_STR', None)
conala
15411107-89
Delete an item with key `key` from `mydict`
del mydict[key]
[]
del VAR_STR[VAR_STR]
conala
15411107-82
Delete an item with key `key` from `mydict`
try: del mydict[key] except KeyError: pass try: del mydict[key] except KeyError: pass
[]
try: del VAR_STR[VAR_STR] except KeyError: pass try: del VAR_STR[VAR_STR] except KeyError: pass
conala
19819863-80
convert hex '\xff' to integer
ord('\xff')
[ "python.library.functions#ord" ]
ord('VAR_STR')
conala
32722143-13
run flask application `app` in debug mode.
app.run(debug=True)
[ "python.library.pdb#pdb.run" ]
VAR_STR.run(debug=True)
conala
4581646-14
Get total number of values in a nested dictionary `food_colors`
sum(len(x) for x in list(food_colors.values()))
[ "python.library.functions#len", "python.library.functions#sum", "python.library.functions#list", "python.library.stdtypes#dict.values" ]
sum(len(x) for x in list(VAR_STR.values()))
conala
4581646-42
count all elements in a nested dictionary `food_colors`
sum(len(v) for v in food_colors.values())
[ "python.library.functions#len", "python.library.functions#sum", "python.library.stdtypes#dict.values" ]
sum(len(v) for v in VAR_STR.values())
conala
27516849-33
concatenate sequence of numpy arrays `LIST` into a one dimensional array along the first axis
numpy.concatenate(LIST, axis=0)
[ "numpy.reference.generated.numpy.concatenate" ]
numpy.concatenate(VAR_STR, axis=0)
conala
517355-78
print '[1, 2, 3]'
print('[%s, %s, %s]' % (1, 2, 3))
[]
print('[%s, %s, %s]' % (1, 2, 3))
conala
517355-35
Display `1 2 3` as a list of string
print('[{0}, {1}, {2}]'.format(1, 2, 3))
[ "python.library.functions#format" ]
print('[{0}, {1}, {2}]'.format(1, 2, 3))
conala
16883447-58
read file 'myfile' using encoding 'iso-8859-1'
codecs.open('myfile', 'r', 'iso-8859-1').read()
[ "python.library.codecs#codecs.open", "python.library.codecs#codecs.StreamReader.read" ]
codecs.open('VAR_STR', 'r', 'VAR_STR').read()
conala
26367812-93
append `date` to list value of `key` in dictionary `dates_dict`, or create key `key` with value `date` in a list if it does not exist
dates_dict.setdefault(key, []).append(date)
[ "python.library.stdtypes#dict.setdefault", "numpy.reference.generated.numpy.append" ]
VAR_STR.setdefault(VAR_STR, []).append(VAR_STR)
conala
19121722-38
build dictionary with keys of dictionary `_container` as keys and values of returned value of function `_value` with correlating key as parameter
{_key: _value(_key) for _key in _container}
[]
{_key: VAR_STR(_key) for _key in VAR_STR}
conala
9652832-83
load a tsv file `c:/~/trainSetRel3.txt` into a pandas data frame
DataFrame.from_csv('c:/~/trainSetRel3.txt', sep='\t')
[]
DataFrame.from_csv('VAR_STR', sep='\t')
conala
39600161-2
regular expression matching all but 'aa' and 'bb' for string `string`
re.findall('-(?!aa-|bb-)([^-]+)', string)
[ "python.library.re#re.findall" ]
re.findall('-(?!aa-|bb-)([^-]+)', VAR_STR)
conala
39600161-59
regular expression matching all but 'aa' and 'bb'
re.findall('-(?!aa|bb)([^-]+)', string)
[ "python.library.re#re.findall" ]
re.findall('-(?!aa|bb)([^-]+)', string)
conala
34527388-67
click on the text button 'section-select-all' using selenium python
browser.find_element_by_class_name('section-select-all').click()
[]
browser.find_element_by_class_name('VAR_STR').click()
conala
25474338-15
regex for repeating words in a string `s`
re.sub('(?<!\\S)((\\S+)(?:\\s+\\2))(?:\\s+\\2)+(?!\\S)', '\\1', s)
[ "python.library.re#re.sub" ]
re.sub('(?<!\\S)((\\S+)(?:\\s+\\2))(?:\\s+\\2)+(?!\\S)', '\\1', VAR_STR)
conala
27966626-90
clear the textbox `text` in tkinter
tex.delete('1.0', END)
[ "python.library.ast#ast.Delete" ]
tex.delete('1.0', END)
conala
11613284-26
get a dictionary with keys from one list `keys` and values from other list `data`
dict(zip(keys, zip(*data)))
[ "python.library.functions#zip", "python.library.stdtypes#dict" ]
dict(zip(VAR_STR, zip(*VAR_STR)))
conala
4152376-23
create a list containing the `n` next values of generator `it`
[next(it) for _ in range(n)]
[ "python.library.functions#range", "python.library.functions#next" ]
[next(VAR_STR) for _ in range(VAR_STR)]
conala
4152376-40
get list of n next values of a generator `it`
list(itertools.islice(it, 0, n, 1))
[ "python.library.itertools#itertools.islice", "python.library.functions#list" ]
list(itertools.islice(VAR_STR, 0, n, 1))
conala
4315506-84
convert csv file 'test.csv' into two-dimensional matrix
numpy.loadtxt(open('test.csv', 'rb'), delimiter=',', skiprows=1)
[ "numpy.reference.generated.numpy.loadtxt", "python.library.urllib.request#open" ]
numpy.loadtxt(open('VAR_STR', 'rb'), delimiter=',', skiprows=1)
conala
775296-19
MySQL execute query 'SELECT * FROM foo WHERE bar = %s AND baz = %s' with parameters `param1` and `param2`
c.execute('SELECT * FROM foo WHERE bar = %s AND baz = %s', (param1, param2))
[ "python.library.msilib#msilib.View.Execute" ]
c.execute('VAR_STR', (VAR_STR, VAR_STR))
conala
14247586-5
get data of columns with Null values in dataframe `df`
df[pd.isnull(df).any(axis=1)]
[ "pandas.reference.api.pandas.isnull", "python.library.functions#any" ]
VAR_STR[pd.isnull(VAR_STR).any(axis=1)]
conala
14507794-7
Collapse hierarchical column index to level 0 in dataframe `df`
df.columns = df.columns.get_level_values(0)
[]
VAR_STR.columns = VAR_STR.columns.get_level_values(0)
conala
24958010-61
get keys with same value in dictionary `d`
print([key for key in d if d[key] == 1])
[]
print([key for key in VAR_STR if VAR_STR[key] == 1])
conala
24958010-12
get keys with same value in dictionary `d`
print([key for key, value in d.items() if value == 1])
[ "python.library.stdtypes#dict.items" ]
print([key for key, value in VAR_STR.items() if value == 1])
conala
24958010-69
Get keys from a dictionary 'd' where the value is '1'.
print([key for key, value in list(d.items()) if value == 1])
[ "python.library.functions#list", "python.library.stdtypes#dict.items" ]
print([key for key, value in list(VAR_STR.items()) if value == 1])
conala
2813829-29
coalesce non-word-characters in string `a`
print(re.sub('(\\W)\\1+', '\\1', a))
[ "python.library.re#re.sub" ]
print(re.sub('(\\W)\\1+', '\\1', VAR_STR))
conala
14932247-15
variable number of digits `digits` in variable `value` in format string "{0:.{1}%}"
"""{0:.{1}%}""".format(value, digits)
[ "python.library.functions#format" ]
"""VAR_STR""".format(VAR_STR, VAR_STR)
conala
40384599-21
sort list `a` in ascending order based on the addition of the second and third elements of each tuple in it
sorted(a, key=lambda x: (sum(x[1:3]), x[0]))
[ "python.library.functions#sorted", "python.library.functions#sum" ]
sorted(VAR_STR, key=lambda x: (sum(x[1:3]), x[0]))
conala
40384599-36
sort a list of tuples `a` by the sum of second and third element of each tuple
sorted(a, key=lambda x: (sum(x[1:3]), x[0]), reverse=True)
[ "python.library.functions#sorted", "python.library.functions#sum" ]
sorted(VAR_STR, key=lambda x: (sum(x[1:3]), x[0]), reverse=True)
conala
40384599-2
sorting a list of tuples `lst` by the sum of the second elements onwards, and third element of the tuple
sorted(lst, key=lambda x: (sum(x[1:]), x[0]))
[ "python.library.functions#sorted", "python.library.functions#sum" ]
sorted(VAR_STR, key=lambda x: (sum(x[1:]), x[0]))
conala
40384599-2
sort the list of tuples `lst` by the sum of every value except the first and by the first value in reverse order
sorted(lst, key=lambda x: (sum(x[1:]), x[0]), reverse=True)
[ "python.library.functions#sorted", "python.library.functions#sum" ]
sorted(VAR_STR, key=lambda x: (sum(x[1:]), x[0]), reverse=True)
conala
13840379-89
multiply all items in a list `[1, 2, 3, 4, 5, 6]` together
from functools import reduce reduce(lambda x, y: x * y, [1, 2, 3, 4, 5, 6])
[]
from functools import reduce reduce(lambda x, y: x * y, [VAR_STR])
conala