Is the use of strings with {} placeholders and their .format() method
integral part of "decoding byte strings before printing", or it is just
a new/better/improved/subjectively-preferred/whatever style?
If the latter, such a change should be separated into its own step,
or at least needs to be mentioned and justified in the proposed log
message.
Lack of explanation on "why" is shared among all these patches, it
seems, so I won't repeat, but the patches need to explain why to
their readers.
Is the use of strings with {} placeholders and their .format() method
integral part of "decoding byte strings before printing", or it is just
a new/better/improved/subjectively-preferred/whatever style?
If the new minimum python version will be 3.6 or above I'd vote for using
f-Strings instead of .format() which I think are more readable and are also
supposed to be faster.
So:
sys.stdout.write(f'\r{file_path} --> {rel_path} ({size/1024/1024} MB)\n')
instead of one of these:
sys.stdout.write('\r%s --> %s (%i MB)\n' % (file_path, relPath, size/1024/1024))
sys.stdout.write('\r{} --> {} ({} MB)\n'.format(file_path.decode(), relPath,
size/1024/1024))
From: Joel Holdsworth <hidden> Date: 2021-12-10 10:41:52
Is the use of strings with {} placeholders and their .format() method integral
part of "decoding byte strings before printing", or it is just a
new/better/improved/subjectively-preferred/whatever style?
If the latter, such a change should be separated into its own step, or at least
needs to be mentioned and justified in the proposed log message.
As I mentioned in my other message, I would like to invest some time into tidying and modernising the script - as well as fixing bugs and improving behaviour. If I submit patches that only make subjective style improvements, are these likely to be accepted?
Lack of explanation on "why" is shared among all these patches, it seems, so I
won't repeat, but the patches need to explain why to their readers.
From: Joel Holdsworth <hidden> Date: 2021-12-10 10:48:51
If the new minimum python version will be 3.6 or above I'd vote for using f-
Strings instead of .format() which I think are more readable and are also
supposed to be faster.
Time passes so fast - I would prefer to use f-strings, but I didn't realise that they were universally available yet. They're still a "new thing" as far as I'm concerned.
I would prefer f-strings, I just used the str.format() method as a middle-ground.
So:
sys.stdout.write(f'\r{file_path} --> {rel_path} ({size/1024/1024} MB)\n')
By the way, I have a patch coming soon that can print the size in human readable units: b, kb, Mb, Gb etc. rather than always converting it to Mb.