Break lines?
I have made this string: TITLE = 'Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer' But I am not allowed to break the line like that: IndentationError: unexpected indent How do I break a line? -- http://mail.python.org/mailman/listinfo/python-list
Re: Break lines?
Tim Chase wrote:
>> I have made this string:
>>
>> TITLE = 'Efficiency of set operations: sort model,
>> (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer'
>>
>> But I am not allowed to break the line like that:
>>
>> IndentationError: unexpected indent
>>
>> How do I break a line?
>
> Depends on what you want. You can embed running strings with newlines
> using triple-quotes (either single- or double-quotes):
>
> TITLE = """Efficiency...
>(cphstl:..."""
>
>
> Or you can use string concatenation using line-continuations:
>
> TITLE = "Efficiency..." \
>"(cphstl:..."
>
> or using parens
>
> TITLE = ("Efficiency..."
>"(cphstl:...")
>
>
>
> I like the clean'ness of the first version, but sometimes get irked by
> it including my leading whitespace (there are some workarounds, but all
> involve more than trivial effort). I tend to use the 2nd in the case
> you describe, but usually using the 3rd version in all other cases where
> it's as a parameter to a function call or some other bracketed/braced
> construct.
>
> -tkc
>
>
Ok thanks! Btw why double quotes " instead of single ' ?
--
http://mail.python.org/mailman/listinfo/python-list
Platform independent code?
I have read that Python is a platform independent language. But on this
page:
http://docs.python.org/tut/node4.html#SECTION00422
it seems that making a python script executable is platform dependant:
2.2.2 Executable Python Scripts
On BSD'ish Unix systems, Python scripts can be made directly executable,
like shell scripts, by putting the line
#! /usr/bin/env python
(assuming that the interpreter is on the user's PATH) at the beginning of
the script and giving the file an executable mode. The "#!" must be the
first two characters of the file. On some platforms, this first line must
end with a Unix-style line ending ("\n"), not a Mac OS ("\r") or Windows
("\r\n") line ending. Note that the hash, or pound, character, "#", is used
to start a comment in Python.
The script can be given an executable mode, or permission, using the chmod
command:
$ chmod +x myscript.py
Are there any guidelines (API'S) that gurantees that the python code will be
platform independent?
--
http://mail.python.org/mailman/listinfo/python-list
