triple quoted strings as comments
dmh2000
dmh2000 at gmail.com
Mon Jan 30 19:29:15 EST 2006
I recently complained elsewhere that Python doesn't have multiline
comments. i was told to use triple quoted strings to make multiline
comments. My question is that since a triple quoted string is actually
a language construct, does it use cause a runtime construction of a
string which is then discarded, or is the runtime smart enough to see
that it isn't used and so it doesn't construct it?
example
def fun(self):
"""doc comment
comment line 2
"""
x = 1
y = 2
"""does this triple quoted string used as a comment
cause something to happen at runtime beyond
just skipping over it? Such as allocation of memory for a string
or worse yet garbage collection? or not?
"""
z = x + y
...
dave howard
More information about the Python-list
mailing list