I enforce strictly 80 characters per line in my python codes, but occasionally I have to break a line of string into two as following
print time.strftime("%m/%d/%Y %I:%M:%S \
%p",time.localtime(os.path.getmtime(fname)))
in which case the output will have extra spaces in front of the “AM/PM”, like
foo.dat was last modified: 01/10/2012 02:53:15 AM
There are easy way to fix this, simply to either avoid cutting off strings, or allow long lines in this case, however, I am wondering if there are other more intrinsic ways to tackle this while allowing both str-cutting and line-breaking to happen. The second line is automatically indented by the editor, I don’t want to change that either. Thanks.
The recommended way to do this is to avoid using
\altogether by using parentheses instead. Also, use the fact that consecutive strings are concatenated into one string. For example: