/// <summary> /// Get Method /// </summary> /// <remarks> /// Obtain the value of the variable of given name, /// and convert the result to a Managed Object of given type. /// If the variable does not exist, throw an Exception. /// </remarks> public T Get <T>(string name) { Check(); PyObject pyObj = Get(name); if (pyObj == null) { return(default(T)); } return(pyObj.As <T>()); }
/// <summary> /// Execute method /// </summary> /// <remarks> /// Execute a Python ast and return the result as a PyObject, /// and convert the result to a Managed Object of given type. /// The ast can be either an expression or stmts. /// </remarks> public T Execute <T>(PyObject script, PyDict locals = null) { Check(); PyObject pyObj = Execute(script, locals); if (pyObj == null) { return(default(T)); } var obj = pyObj.As <T>(); return(obj); }
public static T T <T>(PyObject obj) { return(obj.As <T>()); }
public override object ToClr(PyObject pyObj) { return(pyObj.As <double>()); }
public override object ToClr(PyObject pyObj) { return(pyObj.As <float>()); }
public override object ToClr(PyObject pyObj) { return(pyObj.As <long>()); }