I’ve created a small python script to toggle between two files I’m using for testing.
My question is, what is a good Python format style for the following code:
import filecmp import shutil local = 'local.txt' remote = 'remote.txt' config_file = 'C:\some\path\file.txt' shutil.copyfile( remote if( filecmp.cmp(local, config_file ) ) else local, config_file )
Or
shutil.copyfile( remote if( filecmp.cmp(local, config_file ) ) else local, config_file )
Or
tocopy = remote if( filecmp.cmp( local, config_file ) ) else local shutil.copyfile( tocopy, config_file )
Or what?
Also, what is the preferred way to name var in python for many-word names, is it ‘to_copy’, ‘tocopy’, ‘toCopy’, ‘ToCopy’
For the conditional statement, I would probably go with:
There’s little need to use the inline
y if x else zin this case, since the surrounding code is simple enough.