Redefining built-in 'filter'
62
63layout=app_layout()
64
65def filter(year, category, rows, labels, remove=False): 66 cu_index, co_index = [index for index in years.transpose().index if years[index].iloc[0] == year]
67
68 filtered = rows[0:-1] if remove else rows
Redefining built-in 'filter'
69layout = app_layout()
70
71
72def filter(year, category, rows, labels, remove=False): 73 cu_index, co_index = [index for index in years.transpose().index if years[index].iloc[0] == year]
74
75 filtered = rows[0:-1] if remove else rows
Redefining built-in 'filter'
68layout = app_layout()
69
70
71def filter(year, category, rows, labels, remove=False): 72 cu_index, co_index = [index for index in years.transpose().index if years[index].iloc[0] == year]
73
74 filtered = rows[0:-2] if remove else rows
Redefining built-in 'filter'
67layout = app_layout()
68
69
70def filter(year, category, rows, labels, remove=False): 71 cu_index, co_index = [index for index in years.transpose().index if years[index].iloc[0] == year]
72
73 filtered = rows[0:-1] if remove else rows
Description
Defining a local variable or function with the same name as a built-in object makes the built-in object unusable within the current scope and makes the code prone to bugs.
Bad practice
dict = {} # dict is a Python builtin!
for idx, student in enumerate(students):
dict[student] = idx
Preferred:
roll_number = {}
for idx, student in enumerate(students):
roll_number[student] = idx