This is a development version (9.18.0.dev) and may be unstable.Go to latest (9.17.0)
{ } Raw JSON

bundles / IPython 9.18.0.dev / IPython / utils / tokenutil / token_at_cursor

function

IPython.utils.tokenutil:token_at_cursor

source: /IPython/utils/tokenutil.py:108

Signature

def token_at_cursor(cell: str, cursor_pos: int = 0) → str

Summary

Get the token at a given cursor

Extended Summary

Used for introspection.

Function calls are prioritized, so the token for the callable will be returned if the cursor is anywhere inside the call.

Parameters

cell : str

A block of Python code

cursor_pos : int

The location of the cursor in the block where the token should be found

Aliases

  • IPython.utils.tokenutil.token_at_cursor