On Wed, 04 Sep 2013 17:02:42 +1000, Ben Finney wrote:
> [email protected] writes:
>
>> how works python interpreter for finding comment ?
>
> It works as specified in the language reference. In particular, see
> <URL:http://docs.python.org/3/reference/lexical_analysis.html#comments>.
>
>> if possible find nested comment ?
>
> Python's comments are line-end comments only. The syntax does not allow
> multi-line nor nested comments.
While that's technically true, you can use bare strings as de facto
comments. The compiler drops any bare strings it sees, so one can nest
pseudo-comments like this:
do_this()
"""
do_that()
do_something() # Make the widget work correctly.
'''
for x in range(5):
do_something_else()
'''
do_something_different()
"""
In the above, everything except do_this() is commented out by being
turned into a string.
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list