Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

Only a few small things I would suggest changing.

Pep8

You should consider formatting your code in accordance with pep8. This is important when sharing code, as the consistent style makes it much easier for other programmers to read your code. There are various tools available to assist in making the code pep8 compliant. I use the PyCharm IDE which will show pep8 violations right in the editor.

ALL_CAPS_IS_FOR_CONSTS

So generally ALL_CAPS is reserved for constant variables. So this sort of thing:

TOTAL_FILE_COUNT = len(CSV_LIST)

is more Pythonic as:

total_file_count = len(CSV_LIST)

And even better is getting rid of this intermediate assignment altogether with:

print("Processing file {}/{}".format(current_file_count, len(CSV_LIST)))

###Testing for presence in dicts

Testing for presence in dicts

Often when you find code checking for a key presence in a dict before performing some work:

if args['CSV_ENCODING'] is not None:
 CSV_ENCODING = args['CSV_ENCODING']

Basically the same thing can be done without the explicit check:

CSV_ENCODING = args.get('CSV_ENCODING', CSV_ENCODING)

Only a few small things I would suggest changing.

Pep8

You should consider formatting your code in accordance with pep8. This is important when sharing code, as the consistent style makes it much easier for other programmers to read your code. There are various tools available to assist in making the code pep8 compliant. I use the PyCharm IDE which will show pep8 violations right in the editor.

ALL_CAPS_IS_FOR_CONSTS

So generally ALL_CAPS is reserved for constant variables. So this sort of thing:

TOTAL_FILE_COUNT = len(CSV_LIST)

is more Pythonic as:

total_file_count = len(CSV_LIST)

And even better is getting rid of this intermediate assignment altogether with:

print("Processing file {}/{}".format(current_file_count, len(CSV_LIST)))

###Testing for presence in dicts

Often when you find code checking for a key presence in a dict before performing some work:

if args['CSV_ENCODING'] is not None:
 CSV_ENCODING = args['CSV_ENCODING']

Basically the same thing can be done without the explicit check:

CSV_ENCODING = args.get('CSV_ENCODING', CSV_ENCODING)

Only a few small things I would suggest changing.

Pep8

You should consider formatting your code in accordance with pep8. This is important when sharing code, as the consistent style makes it much easier for other programmers to read your code. There are various tools available to assist in making the code pep8 compliant. I use the PyCharm IDE which will show pep8 violations right in the editor.

ALL_CAPS_IS_FOR_CONSTS

So generally ALL_CAPS is reserved for constant variables. So this sort of thing:

TOTAL_FILE_COUNT = len(CSV_LIST)

is more Pythonic as:

total_file_count = len(CSV_LIST)

And even better is getting rid of this intermediate assignment altogether with:

print("Processing file {}/{}".format(current_file_count, len(CSV_LIST)))

Testing for presence in dicts

Often when you find code checking for a key presence in a dict before performing some work:

if args['CSV_ENCODING'] is not None:
 CSV_ENCODING = args['CSV_ENCODING']

Basically the same thing can be done without the explicit check:

CSV_ENCODING = args.get('CSV_ENCODING', CSV_ENCODING)
Source Link
Stephen Rauch
  • 4.3k
  • 12
  • 24
  • 36

Only a few small things I would suggest changing.

Pep8

You should consider formatting your code in accordance with pep8. This is important when sharing code, as the consistent style makes it much easier for other programmers to read your code. There are various tools available to assist in making the code pep8 compliant. I use the PyCharm IDE which will show pep8 violations right in the editor.

ALL_CAPS_IS_FOR_CONSTS

So generally ALL_CAPS is reserved for constant variables. So this sort of thing:

TOTAL_FILE_COUNT = len(CSV_LIST)

is more Pythonic as:

total_file_count = len(CSV_LIST)

And even better is getting rid of this intermediate assignment altogether with:

print("Processing file {}/{}".format(current_file_count, len(CSV_LIST)))

###Testing for presence in dicts

Often when you find code checking for a key presence in a dict before performing some work:

if args['CSV_ENCODING'] is not None:
 CSV_ENCODING = args['CSV_ENCODING']

Basically the same thing can be done without the explicit check:

CSV_ENCODING = args.get('CSV_ENCODING', CSV_ENCODING)
lang-py

AltStyle によって変換されたページ (->オリジナル) /