how to detect comment in source code file ?

Paul Rudin paul at rudin.co.uk
Wed Sep 4 03:18:23 EDT 2013


Ben Finney <ben+python at benfinney.id.au> writes:

> vnkumbhani at gmail.com 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.

Although you can use unbound multi-line strings as a kind of
comment. But its often better to make the strings into doc strings
proper.



More information about the Python-list mailing list