MCPcopy Index your code
hub / github.com/ipython/ipython / semicolon_at_end_of_expression

Method semicolon_at_end_of_expression

IPython/core/displayhook.py:100–112  ·  view source on GitHub ↗

Parse Python expression and detects whether last token is ';

(expression)

Source from the content-addressed store, hash-verified

98
99 @staticmethod
100 def semicolon_at_end_of_expression(expression):
101 """Parse Python expression and detects whether last token is ';'"""
102
103 sio = _io.StringIO(expression)
104 tokens = list(tokenize.generate_tokens(sio.readline))
105
106 for token in reversed(tokens):
107 if token[0] in (tokenize.ENDMARKER, tokenize.NL, tokenize.NEWLINE, tokenize.COMMENT):
108 continue
109 if (token[0] == tokenize.OP) and (token[1] == ';'):
110 return True
111 else:
112 return False
113
114 def start_displayhook(self):
115 """Start the displayhook, initializing resources."""

Callers 4

quietMethod · 0.95
run_line_magicMethod · 0.80
run_cell_magicMethod · 0.80
captureMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected