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

Method __call__

IPython/terminal/embed.py:194–263  ·  view source on GitHub ↗

Activate the interactive interpreter. __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start the interpreter shell with the given local and global namespaces, and optionally print a header string at startup. The shell can be globally activated/deacti

(
        self,
        header="",
        local_ns=None,
        module=None,
        dummy=None,
        stack_depth=1,
        compile_flags=None,
        **kw,
    )

Source from the content-addressed store, hash-verified

192 self.register_magics(EmbeddedMagics)
193
194 def __call__(
195 self,
196 header="",
197 local_ns=None,
198 module=None,
199 dummy=None,
200 stack_depth=1,
201 compile_flags=None,
202 **kw,
203 ):
204 """Activate the interactive interpreter.
205
206 __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start
207 the interpreter shell with the given local and global namespaces, and
208 optionally print a header string at startup.
209
210 The shell can be globally activated/deactivated using the
211 dummy_mode attribute. This allows you to turn off a shell used
212 for debugging globally.
213
214 However, *each* time you call the shell you can override the current
215 state of dummy_mode with the optional keyword parameter 'dummy'. For
216 example, if you set dummy mode on with IPShell.dummy_mode = True, you
217 can still have a specific call work by making it as IPShell(dummy=False).
218 """
219
220 # we are called, set the underlying interactiveshell not to exit.
221 self.keep_running = True
222
223 # If the user has turned it off, go away
224 clid = kw.pop('_call_location_id', None)
225 if not clid:
226 frame = sys._getframe(1)
227 clid = '%s:%s' % (frame.f_code.co_filename, frame.f_lineno)
228 self._call_location_id = clid
229
230 if not self.embedded_active:
231 return
232
233 # Normal exits from interactive mode set this flag, so the shell can't
234 # re-enter (it checks this variable at the start of interactive mode).
235 self.exit_now = False
236
237 # Allow the dummy parameter to override the global __dummy_mode
238 if dummy or (dummy != 0 and self.dummy_mode):
239 return
240
241 # self.banner is auto computed
242 if header:
243 self.old_banner2 = self.banner2
244 self.banner2 = self.banner2 + '\n' + header + '\n'
245 else:
246 self.old_banner2 = ''
247
248 if self.display_banner:
249 self.show_banner()
250
251 # Call the embedding code with a stack depth of 1 so it can skip over

Callers

nothing calls this directly

Calls 4

mainloopMethod · 0.95
KillEmbeddedClass · 0.85
popMethod · 0.80
show_bannerMethod · 0.80

Tested by

no test coverage detected