Is there a correct way to show file paths (hard coded) longer than 79 characters (based on pep8) on multiply lines or is it best to keep the file path on a single line?
Eg
photos = "D:\MyWork\FieldWork\Year2015\January\MountainPass\Area1\Site1\Campsite2\Inspections\photos1"
Would the above example work best on multiple lines or a single line?
I personally use this method, and have seen it used in the PEP8 materials:
long_string = ('this is a really long string I want '
'to wrap over multiple lines')
You can also do:
long_string = 'this is a really long string I want '\
'to wrap over multiple lines'
According to PEP8 you should try to keep the maximum width of code to 79 characters, and generally docstrings and comments to 72.
I also recommend taking a look at os.path
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With