neulab/docprompting-conala huggingface dataset:
# split a string `yas` based on tab '\t'
re.split('\\t+', yas.rstrip('\t'))
# sorting the lists in list of lists `data`
[sorted(item) for item in data]
# remove identical items from list `my_list` and sort it alphabetically
sorted(set(my_list))
# convert a list of lists `a` into list of tuples of appropriate elements form nested lists
zip(*a)
# converting hex string `s` to its integer representations
[ord(c) for c in s.decode('hex')]
# create pandas data frame `df` from txt file `filename.txt` with column `Region Name` and separator `;`
df = pd.read_csv('filename.txt', sep=';', names=['Region Name'])
# get a list of all the duplicate items in dataframe `df` using pandas
pd.concat(g for _, g in df.groupby('ID') if len(g) > 1)
# sort objects in model `Profile` based on Theirs `reputation` attribute
sorted(Profile.objects.all(), key=lambda p: p.reputation)
# for a dictionary `a`, set default value for key `somekey` as list and append value `bob`  in that key
a.setdefault('somekey', []).append('bob')
# replace white spaces in string '  a\n b\n c\nd  e' with empty string ''
re.sub('(?m)^[^\\S\\n]+', '', '  a\n b\n c\nd  e')
# remove white spaces from all the lines using a regular expression in string 'a\n b\n c'
re.sub('(?m)^\\s+', '', 'a\n b\n c')
# sort dataframe `df` based on column 'b' in ascending and column 'c' in descending
df.sort_values(['b', 'c'], ascending=[True, False], inplace=True)
# sort dataframe `df` based on column 'a' in ascending and column 'b' in descending
df.sort_values(['a', 'b'], ascending=[True, False])
# sort a pandas data frame with column `a` in ascending and `b` in descending order
df1.sort(['a', 'b'], ascending=[True, False], inplace=True)
# sort a pandas data frame by column `a` in ascending, and by column `b` in descending order
df.sort(['a', 'b'], ascending=[True, False])
# create a symlink directory `D:\\testdirLink` for directory `D:\\testdir` with unicode support using ctypes library
kdll.CreateSymbolicLinkW('D:\\testdirLink', 'D:\\testdir', 1)
# Sort a list of dictionaries `mylist` by keys "weight" and "factor"
mylist.sort(key=operator.itemgetter('weight', 'factor'))
# ordering a list of dictionaries `mylist` by elements 'weight' and 'factor'
mylist.sort(key=lambda d: (d['weight'], d['factor']))
# convert tuple elements in list `[(1,2),(3,4),(5,6),]` into lists
map(list, zip(*[(1, 2), (3, 4), (5, 6)]))
# convert list of tuples to multiple lists in Python
map(list, zip(*[(1, 2), (3, 4), (5, 6)]))
# convert list of tuples to multiple lists in Python
zip(*[(1, 2), (3, 4), (5, 6)])
# derive the week start for the given week number and year ‘2011, 4, 0’
datetime.datetime.strptime('2011, 4, 0', '%Y, %U, %w')
# python selenium click on button '.button.c_button.s_button'
driver.find_element_by_css_selector('.button.c_button.s_button').click()
# python selenium click on button
driver.find_element_by_css_selector('.button .c_button .s_button').click()
# read CSV file 'my.csv' into a dataframe `df` with datatype of float for column 'my_column' considering character 'n/a' as NaN value
df = pd.read_csv('my.csv', dtype={'my_column': np.float64}, na_values=['n/a'])
# convert nan values to ‘n/a’ while reading rows from a csv `read_csv` with pandas
df = pd.read_csv('my.csv', na_values=['n/a'])
# get indexes of all true boolean values from a list `bool_list`
[i for i, elem in enumerate(bool_list, 1) if elem]
# get a list `no_integers` of all the items in list `mylist` that are not of type `int`
no_integers = [x for x in mylist if not isinstance(x, int)]
# concatenating values in `list1` to a string
str1 = ''.join(list1)
# concatenating values in list `L` to a string, separate by space
' '.join((str(x) for x in L))
# concatenating values in `list1` to a string
str1 = ''.join((str(e) for e in list1))
# concatenating values in list `L` to a string
makeitastring = ''.join(map(str, L))
# find consecutive segments from a column 'A' in a pandas data frame 'df'
df.reset_index().groupby('A')['index'].apply(np.array)
# place '\' infront of each non-letter char in string `line`
print(re.sub('[_%^$]', '\\\\\\g<0>', line))
# sort a list of tuples `my_list` by second parameter in the tuple
my_list.sort(key=lambda x: x[1])
# execute a file './abc.py' with arguments `arg1` and `arg2` in python shell
subprocess.call(['./abc.py', arg1, arg2])
# find the string matches within parenthesis from a string `s` using regex
m = re.search('\\[(\\w+)\\]', s)
# Add row `['8/19/2014', 'Jun', 'Fly', '98765']` to dataframe `df`
df.loc[len(df)] = ['8/19/2014', 'Jun', 'Fly', '98765']
# decode the string 'stringnamehere'  to UTF-8
stringnamehere.decode('utf-8', 'ignore')
# convert string `apple` from iso-8859-1/latin1 to utf-8
apple.decode('iso-8859-1').encode('utf8')
# create datetime object from "16sep2012"
datetime.datetime.strptime('16Sep2012', '%d%b%Y')
# add key "item3" and value "3" to dictionary `default_data `
default_data['item3'] = 3
# add key "item3" and value "3" to dictionary `default_data `
default_data.update({'item3': 3, })
# add key value pairs 'item4' , 4 and 'item5' , 5 to dictionary `default_data`
default_data.update({'item4': 4, 'item5': 5, })
# split strings in list `l` on the first occurring tab `\t` and enter only the first resulting substring in a new list
[i.split('\t', 1)[0] for i in l]
# Split each string in list `myList` on the tab character
myList = [i.split('\t')[0] for i in myList]
# search for occurrences of regex pattern `pattern` in string `url`
print(pattern.search(url).group(1))
# convert all of the items in a list `lst` to float
[float(i) for i in lst]
# encode string `data` using hex 'hex' encoding
print(data.encode('hex'))
# Return the decimal value for each hex character in data `data`
print(' '.join([str(ord(a)) for a in data]))
# encode value of key `City` in dictionary `data` as `ascii`, ignoring non-ascii characters
data['City'].encode('ascii', 'ignore')
# Get all matching patterns 'a.*?a' from a string 'a 1 a 2 a 3 a 4 a'.
re.findall('(?=(a.*?a))', 'a 1 a 2 a 3 a 4 a')
# select all rows in dataframe `df` where the values of column 'columnX' is bigger than or equal to `x` and smaller than or equal to `y`
df[(x <= df['columnX']) & (df['columnX'] <= y)]
# remove parentheses only around single words in a string `s` using regex
re.sub('\\((\\w+)\\)', '\\1', s)
# add variable `var` to key 'f' of first element in JSON data `data`
data[0]['f'] = var
# merge pandas dataframe `x` with columns 'a' and 'b' and dataframe `y` with column 'y'
pd.merge(y, x, on='k')[['a', 'b', 'y']]
# concatenate key/value pairs in dictionary `a` with string ', ' into a single string
""", """.join([(str(k) + ' ' + str(v)) for k, v in list(a.items())])
# match regex pattern 'a*?bc*?' on string 'aabcc' with DOTALL enabled
re.findall('a*?bc*?', 'aabcc', re.DOTALL)
# list all files in directory "."
for (dirname, dirnames, filenames) in os.walk('.'):
    for subdirname in dirnames:
        print(os.path.join(dirname, subdirname))
    for filename in filenames:
        pass
# split a `utf-8` encoded string `stru` into a list of characters
list(stru.decode('utf-8'))
# convert a string `s` to its base-10 representation
int(s.encode('hex'), 16)
# sort a zipped list `zipped` using lambda function
sorted(zipped, key=lambda x: x[1])
# How do I sort a zipped list in Python?
zipped.sort(key=lambda t: t[1])
# print script's directory
print(os.path.dirname(os.path.realpath(__file__)))
# find all the rows in Dataframe 'df2' that are also present in Dataframe 'df1', for the columns 'A', 'B', 'C' and 'D'.
pd.merge(df1, df2, on=['A', 'B', 'C', 'D'], how='inner')
# check if all of the following items in list `['a', 'b']` are in a list `['a', 'b', 'c']`
set(['a', 'b']).issubset(['a', 'b', 'c'])
# Check if all the items in a list `['a', 'b']` exists in another list `l`
set(['a', 'b']).issubset(set(l))
# split string `string` on whitespaces using a generator
return (x.group(0) for x in re.finditer("[A-Za-z']+", string))
# generate a list containing values associated with the key 'value' of each dictionary inside list `list_of_dicts`
[x['value'] for x in list_of_dicts]
# python getting a list of value from list of dict
[d['value'] for d in l]
# python getting a list of value from list of dict
[d['value'] for d in l if 'value' in d]
# BeautifulSoup find all 'tr' elements in HTML string `soup` at the five stride starting from the fourth element
rows = soup.findAll('tr')[4::5]
# get a utf-8 string literal representation of byte string `x`
"""x = {}""".format(x.decode('utf8')).encode('utf8')
# extract elements at indices (1, 2, 5) from a list `a`
[a[i] for i in (1, 2, 5)]
# sort list `a` using the first dimension of the element as the key to list `b`
a.sort(key=lambda x: b.index(x[0]))
# How to sort a list according to another list?
a.sort(key=lambda x_y: b.index(x_y[0]))
# Convert a Unicode string `title` to a 'ascii' string
unicodedata.normalize('NFKD', title).encode('ascii', 'ignore')
# Convert a Unicode string `a` to a 'ascii' string
a.encode('ascii', 'ignore')
# delete all occureces of `8` in each string `s` in list `lst`
print([s.replace('8', '') for s in lst])
# replace values of dataframe `df` with True if numeric
df.applymap(lambda x: isinstance(x, (int, float)))
# convert values in dictionary `d` into integers
{k: int(v) for k, v in d.items()}
# generate the combinations of 3 from a set `{1, 2, 3, 4}`
print(list(itertools.combinations({1, 2, 3, 4}, 3)))
# double each character in string `text.read()`
re.sub('(.)', '\\1\\1', text.read(), 0, re.S)
# split a string `a , b; cdf`  using both commas and semicolons as delimeters
re.split('\\s*,\\s*|\\s*;\\s*', 'a , b; cdf')
# Split a string `string` by multiple separators `,` and `;`
[t.strip() for s in string.split(',') for t in s.split(';')]
# sort list `trial_list` based on values of dictionary `trail_dict`
sorted(trial_list, key=lambda x: trial_dict[x])
# merge a list of integers `[1, 2, 3, 4, 5]` into a single integer
from functools import reduce
reduce(lambda x, y: 10 * x + y, [1, 2, 3, 4, 5])
# create a list containing the multiplication of each elements at the same index of list `lista` and list `listb`
[(a * b) for a, b in zip(lista, listb)]
# append a path `/path/to/main_folder` in system path
sys.path.append('/path/to/main_folder')
# check if any of the items in  `search` appear in `string`
any(x in string for x in search)
# select the first row grouped per level 0 of dataframe `df`
df.groupby(level=0, as_index=False).nth(0)
# Escape character '}' in string '{0}:<15}}{1}:<15}}{2}:<8}}' while using function `format` with arguments `('1', '2', '3')`
print('{0}:<15}}{1}:<15}}{2}:<8}}'.format('1', '2', '3'))
# Join data of dataframe `df1` with data in dataframe `df2` based on similar values of column 'user_id' in both dataframes
s1 = pd.merge(df1, df2, how='inner', on=['user_id'])
# parse string '2015/01/01 12:12am' to DateTime object using format '%Y/%m/%d %I:%M%p'
datetime.strptime('2015/01/01 12:12am', '%Y/%m/%d %I:%M%p')
# group dataframe `data` entries by year value of the date in column 'date'
data.groupby(data['date'].map(lambda x: x.year))
# change the size of the sci notation to '30' above the y axis in matplotlib `plt`
plt.rc('font', **{'size': '30'})
# get all column name of dataframe `df` except for column 'T1_V6'
df[df.columns - ['T1_V6']]
# removing key values pairs with key 'mykey1' from a list of dictionaries `mylist`
[{k: v for k, v in d.items() if k != 'mykey1'} for d in mylist]
# Removing key values pairs from a list of dictionaries
[dict((k, v) for k, v in d.items() if k != 'mykey1') for d in mylist]
# strip the string `.txt` from anywhere in the string `Boat.txt.txt`
"""Boat.txt.txt""".replace('.txt', '')
# split string "0,1,2" based on delimiter ','
"""0,1,2""".split(',')
# convert the string '0,1,2' to a list of integers
[int(x) for x in '0,1,2'.split(',')]
# run function 'SudsMove' simultaneously
threading.Thread(target=SudsMove).start()
# execute raw sql queue '<sql here>' in database `db` in sqlalchemy-flask app
result = db.engine.execute('<sql here>')
# What is the most pythonic way to exclude elements of a list that start with a specific character?
[x for x in my_list if not x.startswith('#')]
# Replace `;` with `:` in a string `line`
line = line.replace(';', ':')
# get a list of last trailing words from another list  of strings`Original_List`
new_list = [x.split()[-1] for x in Original_List]
# set the value in column 'B' to NaN if the corresponding value in column 'A' is equal to 0 in pandas dataframe `df`
df.ix[df.A == 0, 'B'] = np.nan
# reset index to default in dataframe `df`
df = df.reset_index(drop=True)
# create a list containing digits of number 123 as its elements
list(str(123))
# converting integer `num` to list
[int(x) for x in str(num)]
# convert generator object to a dictionary
{i: (i * 2) for i in range(10)}
# convert generator object to a dictionary
dict((i, i * 2) for i in range(10))
# move dictionaries in list `lst` to the end of the list if value of key 'language' in each dictionary is not equal to 'en'
sorted(lst, key=lambda x: x['language'] != 'en')
# writing string 'text to write\n' to file `f`
f.write('text to write\n')
# Write a string `My String` to a file `file` including new line character
file.write('My String\n')
# use regex pattern '((.+?)\\2+)' to split string '44442(2)2(2)44'
[m[0] for m in re.compile('((.+?)\\2+)').findall('44442(2)2(2)44')]
# use regular expression '((\\d)(?:[()]*\\2*[()]*)*)' to split string `s`
[i[0] for i in re.findall('((\\d)(?:[()]*\\2*[()]*)*)', s)]
# add character '@' after word 'get' in string `text`
text = re.sub('(\\bget\\b)', '\\1@', text)
# serialize dictionary `d` as a JSON formatted string with each key formatted to pattern '%d,%d'
simplejson.dumps(dict([('%d,%d' % k, v) for k, v in list(d.items())]))
# remove colon character surrounded by vowels letters in string `word`
word = re.sub('([aeiou]):(([aeiou][^aeiou]*){3})$', '\\1\\2', word)
# group dataframe `df` based on minute interval
df.groupby(df.index.map(lambda t: t.minute))
# Execute a post request to url `http://httpbin.org/post` with json data `{'test': 'cheers'}`
requests.post('http://httpbin.org/post', json={'test': 'cheers'})
# delete all digits in string `s` that are not directly attached to a word character
re.sub('$\\d+\\W+|\\b\\d+\\b|\\W+\\d+$', '', s)
# delete digits at the end of string `s`
re.sub('\\b\\d+\\b', '', s)
# Delete self-contained digits from string `s`
s = re.sub('^\\d+\\s|\\s\\d+\\s|\\s\\d+$', ' ', s)
# get the maximum 2 values per row in array `A`
A[:, -2:]
# convert date `my_date` to datetime
datetime.datetime.combine(my_date, datetime.time.min)
# append line "appended text" to file "test.txt"
with open('test.txt', 'a') as myfile:
    myfile.write('appended text')
# append line "cool beans..." to file "foo"
with open('foo', 'a') as f:
    f.write('cool beans...')
# append to file 'test1' content 'koko'
with open('test1', 'ab') as f:
    pass
# append to file 'test' content 'koko'
open('test', 'a+b').write('koko')
# do a boolean check if a string `lestring` contains any of the items in list `lelist`
any(e in lestring for e in lelist)
# combine two columns `foo` and `bar` in a pandas data frame
pandas.concat([df['foo'].dropna(), df['bar'].dropna()]).reindex_like(df)
# sort a list of dictionaries `a` by dictionary values in descending order
sorted(a, key=lambda i: list(i.values())[0], reverse=True)
# sorting a list of dictionary `a` by values in descending order
sorted(a, key=dict.values, reverse=True)
# split string `s` by '@' and get the first element
s.split('@')[0]
# Add a tuple with value `another_choice` to a tuple `my_choices`
final_choices = ((another_choice,) + my_choices)
# pair each element in list `it` 3 times into a tuple
zip(it, it, it)
# store integer 3, 4, 1 and 2 in a list
[3, 4, 1, 2]
# Sorting while preserving order in python
sorted(enumerate(a), key=lambda x: x[1])
# get list of sums of neighboring integers in string `example`
[sum(map(int, s)) for s in example.split()]
# split column 'AB' in dataframe `df` into two columns by first whitespace ' '
df['AB'].str.split(' ', 1, expand=True)
# pandas dataframe, how do i split a column 'AB' into two 'A' and 'B' on delimiter ' '
df['A'], df['B'] = df['AB'].str.split(' ', 1).str
# get multiple parameters with same name from a url in pylons
request.params.getall('c')
# match contents of an element to 'Example' in xpath (lxml)
tree.xpath(".//a[text()='Example']")[0].tag
# find rows of 2d array in 3d numpy array 'arr' if the row has value '[[0, 3], [3, 0]]'
np.argwhere(np.all(arr == [[0, 3], [3, 0]], axis=(1, 2)))
# How to convert a date string '2013-1-25' in format '%Y-%m-%d' to different format '%m/%d/%y'
datetime.datetime.strptime('2013-1-25', '%Y-%m-%d').strftime('%m/%d/%y')
# convert a date string '2013-1-25' in format '%Y-%m-%d' to different format '%-m/%d/%y'
datetime.datetime.strptime('2013-1-25', '%Y-%m-%d').strftime('%-m/%d/%y')
# find the count of a word 'Hello' in a string `input_string`
input_string.count('Hello')
# count the number of trailing question marks in string `my_text`
len(my_text) - len(my_text.rstrip('?'))
# extract dictionary `d` from list `a` where the value associated with the key 'name' of dictionary `d` is equal to 'pluto'
[d for d in a if d['name'] == 'pluto']
# extract dictionary from list of dictionaries based on a key's value.
[d for d in a if d['name'] == 'pluto']
# convert the dataframe column 'col' from string types to datetime types
df['col'] = pd.to_datetime(df['col'])
# remove all non -word, -whitespace, or -apostrophe characters from string `doesn't this mean it -technically- works?`
re.sub("[^\\w' ]", '', "doesn't this mean it -technically- works?")
# find the index of the element with the maximum value from a list 'a'.
max(enumerate(a), key=lambda x: x[1])[0]
# Check if string 'a b' only contains letters and spaces
"""a b""".replace(' ', '').isalpha()
# pad 'dog' up to a length of 5 characters with 'x'
"""{s:{c}^{n}}""".format(s='dog', n=5, c='x')
# find all substrings in string `mystring` composed only of letters `a` and `b` where each `a` is directly preceded and succeeded by `b`
re.findall('\\b(?:b+a)+b+\\b', mystring)
# check if a checkbox is checked in selenium python webdriver
driver.find_element_by_name('<check_box_name>').is_selected()
# determine if checkbox with id '<check_box_id>' is checked in selenium python webdriver
driver.find_element_by_id('<check_box_id>').is_selected()
# Find all keys from a dictionary `d` whose values are `desired_value`
[k for k, v in d.items() if v == desired_value]
# sort a multidimensional array `a` by column with index 1
sorted(a, key=lambda x: x[1])
# sum the length of all strings in a list `strings`
length = sum(len(s) for s in strings)
# Convert a list of lists `lol` to a dictionary with key as second value of a list and value as list itself
{x[1]: x for x in lol}
# get data of column 'A' and column 'B' in dataframe `df` where column 'A' is equal to 'foo'
df.loc[gb.groups['foo'], ('A', 'B')]
# display a pdf  file that has been downloaded as `my_pdf.pdf`
webbrowser.open('file:///my_pdf.pdf')
# sort 2d array `matrix` by row with index 1
sorted(matrix, key=itemgetter(1))
# get the max string length in list `i`
max(len(word) for word in i)
# get the maximum string length in nested list `i`
len(max(i, key=len))
# find all occurrences of the pattern '\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+' within `strs`
re.findall('\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+', strs)
# print a string after a specific substring ', ' in string `my_string `
print(my_string.split(', ', 1)[1])
# extract attribute `my_attr` from each object in list `my_list`
[o.my_attr for o in my_list]
# set the value of cell `['x']['C']` equal to 10 in dataframe `df`
df['x']['C'] = 10
# execute shell command 'grep -r PASSED *.log | sort -u | wc -l' with a | pipe in it
subprocess.call('grep -r PASSED *.log | sort -u | wc -l', shell=True)
# Converting string lists `s` to float list
floats = [float(x) for x in s.split()]
# Converting string lists `s` to float list
floats = map(float, s.split())
# iterate backwards from 10 to 0
range(10, 0, -1)
# Execute Shell Script from python with variable
subprocess.call(['test.sh', str(domid)])
# count the number of integers in list `a`
sum(isinstance(x, int) for x in a)
# play the wav file 'sound.wav'
winsound.PlaySound('sound.wav', winsound.SND_FILENAME)
# save json output from a url ‘http://search.twitter.com/search.json?q=hi’ to file ‘hi.json’ in Python 2
urllib.request.urlretrieve('http://search.twitter.com/search.json?q=hi', 'hi.json')
# remove uppercased characters in string `s`
re.sub('[^A-Z]', '', s)
# Get a list of lists with summing the values of the second element from each list of lists `data`
[[sum([x[1] for x in i])] for i in data]
# summing the second item in a list of lists of lists
[sum([x[1] for x in i]) for i in data]
# apply functions `mean` and `std` to each column in dataframe `df`
df.groupby(lambda idx: 0).agg(['mean', 'std'])
# count the number of non-nan elements in a numpy ndarray matrix `data`
np.count_nonzero(~np.isnan(data))
# How can I resize the root window in Tkinter?
root.geometry('500x500')
# add header 'WWWAuthenticate' in a flask app with value 'Basic realm="test"'
response.headers['WWW-Authenticate'] = 'Basic realm="test"'
# return the column for value 38.15 in dataframe `df`
df.ix[:, (df.loc[0] == 38.15)].columns
# sort two lists `list1` and `list2` together using lambda function
[list(x) for x in zip(*sorted(zip(list1, list2), key=lambda pair: pair[0]))]
# drop duplicate indexes in a pandas data frame `df`
df[~df.index.duplicated()]
# grab one random item from a database `model` in django/postgresql
model.objects.all().order_by('?')[0]
# select a first form with no name in mechanize
br.select_form(nr=0)
# convert a list of objects `list_name` to json string `json_string`
json_string = json.dumps([ob.__dict__ for ob in list_name])
# Get a list comparing two lists of tuples `l1` and `l2` if any first value in `l1` matches with first value in `l2`
[x[0] for x in l1 if any(x[0] == y[0] for y in l2)]
# find the largest integer less than `x`
int(math.ceil(x)) - 1
# remove all words which contains number from a string `words` using regex
re.sub('\\w*\\d\\w*', '', words).strip()
# match a sharp, followed by letters (including accent characters) in string `str1` using a regex
hashtags = re.findall('#(\\w+)', str1, re.UNICODE)
# Concat a list of strings `lst` using string formatting
"""""".join(lst)
# send cookies `cookie` in a post request to url 'http://wikipedia.org' with the python requests library
r = requests.post('http://wikipedia.org', cookies=cookie)
# list comprehension that produces integers between 11 and 19
[i for i in range(100) if i > 10 if i < 20]
# unquote a urlencoded unicode string '%0a'
urllib.parse.unquote('%0a')
# decode url `url` from UTF-16 code to UTF-8 code
urllib.parse.unquote(url).decode('utf8')
# display current time in readable format
time.strftime('%l:%M%p %z on %b %d, %Y')
# replace nans by preceding values in pandas dataframe `df`
df.fillna(method='ffill', inplace=True)
# sort list `list_` based on first element of each tuple and by the length of the second element of each tuple
list_.sort(key=lambda x: [x[0], len(x[1]), x[1]])
# sort a multidimensional list `a` by second and third column
a.sort(key=operator.itemgetter(2, 3))
# Get all indexes of a list `a` where each value is greater than `2`
[i for i in range(len(a)) if a[i] > 2]
# replace special characters in url 'http://spam.com/go/' using the '%xx' escape
urllib.parse.quote('http://spam.com/go/')
# execute a command in the command prompt to list directory contents of the c drive `c:\\'
os.system('dir c:\\')
# Compose keys from dictionary `d1` with respective values in dictionary `d2`
result = {k: d2.get(v) for k, v in list(d1.items())}
# find all the elements that consists value '1' in a list of tuples 'a'
[item for item in a if 1 in item]
# find all elements in a list of tuples `a` where the first element of each tuple equals 1
[item for item in a if item[0] == 1]
# execute os command ''TASKKILL /F /IM firefox.exe''
os.system('TASKKILL /F /IM firefox.exe')
# copy file "/dir/file.ext" to "/new/dir/newname.ext"
shutil.copy2('/dir/file.ext', '/new/dir/newname.ext')
# copy file '/dir/file.ext' to '/new/dir'
shutil.copy2('/dir/file.ext', '/new/dir')