isinstance: Test if a Proxy Object is an Instance of a Python Type

Description Usage Arguments

View source: R/pythonInterface.R

Description

Applies the Python function isinstance() to object. NOTE: this function should be used to test inheritance on the Python side, even if there are proxy classes for everything involved. It is not true (with the present version of the package) that inheritance in Python corresponds to inheritance in R for the proxy classes.

Usage

1
isinstance(object, type, .ev = RPython())

Arguments

object

Any object. The function returns FALSE without further testing if the object is not a proxy object.

type

A character string corresponding to the Python type (not to the name of a proxy class for the type).

A Python error will result if there is no such type, or if object is a proxy from another language. The implementation diverges from a direct mapping into the Python isinstance to handle a Python bizarre for functions: although type(f) causes you to think functions have the obvious type, that doesn't work in isinstance. So the R code uses what works for this case. (Before we get too sarcastic, the problem is similar to that in R from primitives, making class(f) and typeof(f) confusing.)

.ev

an XRPython evaluator, by default and usually the current evaluator.


XRPython documentation built on May 2, 2019, 9:33 a.m.