28.02.18 00:31, Terry Reedy пише:
2. Usually the position of the docstring is used for determining the absolute position of some fragments in the docstring (for example doctests). But since the literal string can contain \n and escaped newlines, and this information is lost in AST, the position of the fragment can be determined accurately.

You obviously meant 'cannot be determined accurately', because for reasons including the ones you gave, the relation between string literals in code and the resulting string objects is many-to-one, (as with int literals).

Yes, thank you for correction.

The reasons are that the relation between lines of source code and lines of the resulting string objects is not easy. The string literal 'a\nb\c' takes one line in the source code, but produces a three-line string object. On other side, the string literal

    '''\
    abc\
    '''

takes three lines in the source code, but produces a single-line string object. And it is not so rare that a docstring starts with an escaped newline.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to