I just accidentally omitted it for a continued line and discovered it
doesn't seem to be needed!!!
Is that a feature of Django's admin app or a trap for the unwary?
Thanks
Mike
It's a python feature.
http://docs.python.org/reference/lexical_analysis.html#string-literal-concatenation
Outside Django, you can see it in the following:
>>> x = ("stuff"
... "morestuff"
... "yetmorestuff"
... )
>>> print x
stuffmorestuffyetmorestuff
>>> {"hello"
... "world": "value"
... "rest of value"
... }
{'helloworld': 'valuerest of value'}
>>> ["list"
... "with"
... "one"
... "element"
... ]
['listwithoneelement']
Strings that abut inside a continuation context (parens, brackets
or braces) are combined together at parsing time. The only thing
to watch out for is the obvious lack of characters inserted, so
you'll want to make sure any spaces/newlines you want get put in
the strings:
>>> s = ("space after this " # you can even include comments
... "so that this reads right")
>>> print s
space after this so that it reads right
(as opposed to "space after thisso that it reads right")
So what you're seeing is the continuation context of parens used
in the call to a *Field object:
class MyModel(Model):
foo = CharField(
...,
help_text="Some help here "
"that continues on the next line"
)
Perfectly reliable and quite helpful at times.
-tim