A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-October/093264.html below:

[Python-Dev] tokenize string literal problem

[Python-Dev] tokenize string literal problem [Python-Dev] tokenize string literal problemC or L Smith smiles at worksmail.net
Sat Oct 24 08:33:10 CEST 2009
C or L Smith wrote:
> PROBLEM
>     I need to find code snippets which are located in docstrings.
> Docstrings, being string literals should be able to be parsed out
> with tokenize. But tokenize is giving the wrong results (or I am
> doing something wrong) for this (pathological) case:   
> 
> foo.py:
> +----
> def bar():
>     """
>     A quoted triple quote is not a closing
>     of this docstring:
>     >>> print '"""'
>     """
>     """ # <-- this is the closing quote
>     pass
> +----
> 

I now see that I've created a code snippet that is invalid. Myopia. The thing that pythonWin was doing correctly was displaying my sample STRING not code. I had delimited the code with triple-single-quotes so it showed up correctly. In fact, if entered as code it would show the need to delimit the docstring contents with ''' rather than """.

Sorry!
/c
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4