MCPcopy Create free account
hub / github.com/ipython/ipython / has_comment

Function has_comment

IPython/core/inputtransformer.py:307–322  ·  view source on GitHub ↗

Indicate whether an input line has (i.e. ends in, or is) a comment. This uses tokenize, so it can distinguish comments from # inside strings. Parameters ---------- src : string A single line input string. Returns ------- comment : bool True if source has

(src)

Source from the content-addressed store, hash-verified

305 return toktypes
306
307def has_comment(src):
308 """Indicate whether an input line has (i.e. ends in, or is) a comment.
309
310 This uses tokenize, so it can distinguish comments from # inside strings.
311
312 Parameters
313 ----------
314 src : string
315 A single line input string.
316
317 Returns
318 -------
319 comment : bool
320 True if source has a comment.
321 """
322 return (tokenize.COMMENT in _line_tokens(src))
323
324def ends_in_comment_or_string(src):
325 """Indicates whether or not an input line ends in a comment or within

Callers 1

assemble_logical_linesFunction · 0.85

Calls 1

_line_tokensFunction · 0.85

Tested by

no test coverage detected