msticpy.common.utility.ipython module

Notebook utility functions.

msticpy.common.utility.ipython.is_ipython(notebook: bool = False) bool

Return True if running in IPython environment.

Parameters

notebook (bool, optional) – If notebook is true this will only return true if running in a Jupyter notebook.

Returns

True if running in IPython environment, otherwise False

Return type

bool

msticpy.common.utility.ipython.md(string: str, styles: Optional[Union[str, Iterable[str]]] = None, disp_id: Optional[Union[bool, IPython.display.DisplayHandle]] = None) IPython.display.DisplayHandle

Display a string as Markdown with optional style.

Parameters
  • string (str) – The string to display

  • styles (Union[str, Iterable[str]], optional) – A style mnemonic or collection of styles. If multiple styles, these can be supplied as an interable of strings or a comma-separated string, by default None

  • disp_id (Optional[Union[bool, DisplayHandle]], optional) – If True, the function will return a display handle that can be re-used in subsequent calls to update the display object. If this is previously-created display handle, this is used as the target display object to update it with the content of this call, by default None

Returns

A handle to the display object that can be used to update the contents.

Return type

DisplayHandle

msticpy.common.utility.ipython.md_error(string: str, disp_id: Optional[IPython.display.DisplayHandle] = None)

Return string as an error - red text prefixed by “Error”.

Parameters
  • string (str) – The error message.

  • disp_id (Optional[Union[bool, DisplayHandle]], optional) – If True, the function will return a display handle that can be re-used in subsequent calls to update the display object. If this is previously-created display handle, this is used as the target display object to update it with the content of this call, by default None

msticpy.common.utility.ipython.md_warn(string: str, disp_id: Optional[IPython.display.DisplayHandle] = None)

Return string as a warning - orange text prefixed by “Warning”.

Parameters
  • string (str) – The warning message.

  • disp_id (Optional[DisplayHandle], optional) – If True, the function will return a display handle that can be re-used in subsequent calls to update the display object. If this is previously-created display handle, this is used as the target display object to update it with the content of this call, by default None

Returns

A handle to the display object that can be used to update the contents.

Return type

DisplayHandle