Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

If I had to pick a least-favourite line in the program, it would be this one:

if 'testrun' in globals():

... because

  • Global variables are bad.
  • You didn't even declare testrun as a global variable using global testrun, but rather you used introspection.
  • You didn't test the flag to see whether it was True or False; you just check for its existence.
  • The whole problem could have been avoided by calling handleResults() with a parameter.

print('%s is not a valid path, please verify' % i)
sys.exit()

When you exit the program due to an error, exit with a non-zero status.

i is an unconventional iteration variable, since it has the connotation of being an integer. The code would be more readable if you had written for folder in folders: ....


In hashfile(), you should call open() using a with block.

Since hashfile() seems like it could be a basic reusable operation, I would avoid having it print anything. The findDup() function, which calls hashfile(), prints status updates, and in fact it prints the same path just before calling hashfile().

If I had to pick a least-favourite line in the program, it would be this one:

if 'testrun' in globals():

... because

  • Global variables are bad.
  • You didn't even declare testrun as a global variable using global testrun, but rather you used introspection.
  • You didn't test the flag to see whether it was True or False; you just check for its existence.
  • The whole problem could have been avoided by calling handleResults() with a parameter.

print('%s is not a valid path, please verify' % i)
sys.exit()

When you exit the program due to an error, exit with a non-zero status.

i is an unconventional iteration variable, since it has the connotation of being an integer. The code would be more readable if you had written for folder in folders: ....


In hashfile(), you should call open() using a with block.

Since hashfile() seems like it could be a basic reusable operation, I would avoid having it print anything. The findDup() function, which calls hashfile(), prints status updates, and in fact it prints the same path just before calling hashfile().

If I had to pick a least-favourite line in the program, it would be this one:

if 'testrun' in globals():

... because

  • Global variables are bad.
  • You didn't even declare testrun as a global variable using global testrun, but rather you used introspection.
  • You didn't test the flag to see whether it was True or False; you just check for its existence.
  • The whole problem could have been avoided by calling handleResults() with a parameter.

print('%s is not a valid path, please verify' % i)
sys.exit()

When you exit the program due to an error, exit with a non-zero status.

i is an unconventional iteration variable, since it has the connotation of being an integer. The code would be more readable if you had written for folder in folders: ....


In hashfile(), you should call open() using a with block.

Since hashfile() seems like it could be a basic reusable operation, I would avoid having it print anything. The findDup() function, which calls hashfile(), prints status updates, and in fact it prints the same path just before calling hashfile().

Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479

If I had to pick a least-favourite line in the program, it would be this one:

if 'testrun' in globals():

... because

  • Global variables are bad.
  • You didn't even declare testrun as a global variable using global testrun, but rather you used introspection.
  • You didn't test the flag to see whether it was True or False; you just check for its existence.
  • The whole problem could have been avoided by calling handleResults() with a parameter.

print('%s is not a valid path, please verify' % i)
sys.exit()

When you exit the program due to an error, exit with a non-zero status.

i is an unconventional iteration variable, since it has the connotation of being an integer. The code would be more readable if you had written for folder in folders: ....


In hashfile(), you should call open() using a with block.

Since hashfile() seems like it could be a basic reusable operation, I would avoid having it print anything. The findDup() function, which calls hashfile(), prints status updates, and in fact it prints the same path just before calling hashfile().

lang-py

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