IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

check_and_get_arg

check_and_get_arg[T: ImplicitlyDestructible](func_name: StringSlice[StaticConstantOrigin], py_args: PythonObject, index: Int) -> UnsafePointer[T, MutAnyOrigin]

Get the argument at the given index and downcast it to a given Mojo type.

Parameters:

Args:

  • func_name (StringSlice[StaticConstantOrigin]): The name of the function referenced in the error message if the downcast fails.
  • py_args (PythonObject): The Python tuple object containing the arguments.
  • index (Int): The index of the argument.

Returns:

UnsafePointer[T, MutAnyOrigin]: A pointer to the Mojo value contained in the argument.

Raises:

If the argument cannot be downcast to the given type.