Skip to main content
added 113 characters in body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

Trailing semicolons

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

Appending to arrays

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

 

Augmented assignment operator +=

Instead of:

l = l + 1

This is shorter and better:

l += 1

 

Use list comprehensions

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

 

Instead of:

l = l + 1

This is shorter and better:

l += 1

 

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

Trailing semicolons

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

Appending to arrays

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Augmented assignment operator +=

Instead of:

l = l + 1

This is shorter and better:

l += 1

Use list comprehensions

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]
deleted 334 characters in body
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Something that really hurts readability here is the variable names:

  • set shadows the name of Python built-in
  • l is a poor name as it a single letter and also easy to confuse with the number 1
  • val is also a poor name

Find better names instead of these, something descriptive that gives more hints to the reader.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

l = l + 1

This is shorter and better:

l += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

Something that really hurts readability here is the variable names:

  • set shadows the name of Python built-in
  • l is a poor name as it a single letter and also easy to confuse with the number 1
  • val is also a poor name

Find better names instead of these, something descriptive that gives more hints to the reader.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

l = l + 1

This is shorter and better:

l += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

l = l + 1

This is shorter and better:

l += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]
deleted 25 characters in body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

Something that really hurts readability here is the variable names that shadow the names of Python built-ins: set, len. Find

  • set shadows the name of Python built-in
  • l is a poor name as it a single letter and also easy to confuse with the number 1
  • val is also a poor name

Find better names instead of these, something descriptive that gives more hints to the reader. The variables val and l could also use better names.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

lenl = lenl + 1

This is shorter and better:

lenl += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

Something that really hurts readability here is the variable names that shadow the names of Python built-ins: set, len. Find better names instead of these, something descriptive that gives more hints to the reader. The variables val and l could also use better names.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

len = len + 1

This is shorter and better:

len += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]

Something that really hurts readability here is the variable names:

  • set shadows the name of Python built-in
  • l is a poor name as it a single letter and also easy to confuse with the number 1
  • val is also a poor name

Find better names instead of these, something descriptive that gives more hints to the reader.

At many places there is a ; at the end of the line. It's completely unnecessary in Python and you should remove those.

At several places you are appending values to arrays in a strange way, for example:

    datedict[val[0]] = datedict[val[0]] + [val[1]];

The common and shorter way to do this is using .append():

    datedict[val[0]].append(val[1])

Instead of:

l = l + 1

This is shorter and better:

l += 1

Instead of:

datearr = []
for dat in daterange(mindate, today):
    datearr = datearr + [datedict[dat]]

You can use a list comprehension, a powerful feature of Python:

datearr = [datedict[dat] for dat in daterange(mindate, today)]
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391
Loading