Alan Gauld wrote: > "Wayne Watson" <[EMAIL PROTECTED]> wrote > >> BTW, how does one continue a long statement >> that has, say, a long path to a file? > > You can create a long string by adding the shorter string > elements : > > f = open( > "a:/very/long/path/name/that/needs/a/whole/line/to./itself.py", > "w") > > becomes > > f = open("a:/very/long/path/name/" + > "that/needs/a/whole/" + > "line/to./itself.py","w") > > > or by using a line continuation character. > > f = open("a:/very/long/path/name/" \ > "that/needs/a/whole/" \ > "line/to./itself.py", "w") >
or just f = open("a:/very/long/path/name/" "that/needs/a/whole/" "line/to./itself.py", "w") because of the enclosing parentheses. This works for expressions in brackets or braces as well -- any enclosing form. PEP8[1] suggests this as the preferred style (adding that "sometimes using a backslash looks better"), which is a little surprising to me, but not in a bad way. Then again, perhaps I've misunderstood -- which would *not* be surprising. # for those who aren't familiar [1] http://www.python.org/dev/peps/pep-0008/ HTH, Marty _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor