bundles / IPython 9.12.0 / IPython / core / interactiveshell / InteractiveShell / find_user_code
function
IPython.core.interactiveshell:InteractiveShell.find_user_code
Signature
def find_user_code ( self , target , raw = True , py_only = False , skip_encoding_cookie = True , search_ns = False ) Summary
Get a code string from history, file, url, or a string or macro.
Extended Summary
This is mainly used by magic functions.
Parameters
target: strA string specifying code to retrieve. This will be tried respectively as: ranges of input history (see %history for syntax), url, corresponding .py file, filename, or an expression evaluating to a string or Macro in the user namespace.
If empty string is given, returns complete history of current session, without the last line.
raw: boolIf true (default), retrieve raw history. Has no effect on the other retrieval mechanisms.
py_only: bool (default False)Only try to fetch python code, do not try alternative methods to decode file if unicode fails.
Returns
: A string of code.: ValueError is raised if nothing is found, and TypeError if it evaluates: to an object of another type. In each case, .args[0] is a printable: message.
Aliases
-
IPython.InteractiveShell.find_user_code