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 usingglobal testrun
, but rather you used introspection. - You didn't test the flag to see whether it was
True
orFalse
; 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 usingglobal testrun
, but rather you used introspection. - You didn't test the flag to see whether it was
True
orFalse
; 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 usingglobal testrun
, but rather you used introspection. - You didn't test the flag to see whether it was
True
orFalse
; 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 usingglobal testrun
, but rather you used introspection. - You didn't test the flag to see whether it was
True
orFalse
; 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()
.