C# Класс Python.Runtime.PyObject

Represents a generic Python object. The methods of this class are generally equivalent to the Python "abstract object API". See http://www.python.org/doc/current/api/object.html for details.
Наследование: System.Dynamic.DynamicObject, IDisposable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
obj IntPtr

Открытые методы

Метод Описание
AsManagedObject ( Type t ) : object

AsManagedObject Method

Return a managed object of the given type, based on the value of the Python object.

DelAttr ( PyObject name ) : void

DelAttr Method

Delete the named attribute of the Python object, where name is a PyObject wrapping a Python string or unicode object. This method throws a PythonException if the attribute set fails.

DelAttr ( string name ) : void

DelAttr Method

Delete the named attribute of the Python object. This method throws a PythonException if the attribute set fails.

DelItem ( PyObject key ) : void

DelItem Method

For objects that support the Python sequence or mapping protocols, delete the item at the given object index. This method raises a PythonException if the delete operation fails.

DelItem ( int index ) : void

DelItem Method

For objects that support the Python sequence or mapping protocols, delete the item at the given numeric index. This method raises a PythonException if the delete operation fails.

DelItem ( string key ) : void

DelItem Method

For objects that support the Python sequence or mapping protocols, delete the item at the given string index. This method raises a PythonException if the delete operation fails.

Dir ( ) : PyList

Dir Method

Return a list of the names of the attributes of the object. This is equivalent to the Python expression "dir(object)".

Dispose ( ) : void
Equals ( object o ) : bool

Equals Method

Return true if this object is equal to the given object. This method is based on Python equality semantics.

FromManagedObject ( object ob ) : PyObject

FromManagedObject Method

Given an arbitrary managed object, return a Python instance that reflects the managed object.

GetAttr ( PyObject name ) : PyObject

GetAttr Method

Returns the named attribute of the Python object or raises a PythonException if the attribute access fails. The name argument is a PyObject wrapping a Python string or unicode object.

GetAttr ( PyObject name, PyObject _default ) : PyObject

GetAttr Method

Returns the named attribute of the Python object, or the given default object if the attribute access fails. The name argument is a PyObject wrapping a Python string or unicode object.

GetAttr ( string name ) : PyObject

GetAttr Method

Returns the named attribute of the Python object, or raises a PythonException if the attribute access fails.

GetAttr ( string name, PyObject _default ) : PyObject

GetAttr Method

Returns the named attribute of the Python object, or the given default object if the attribute access fails.

GetEnumerator ( ) : IEnumerator

GetEnumerator Method

Return a new PyIter object for the object. This allows any iterable python object to be iterated over in C#. A PythonException will be raised if the object is not iterable.

GetHashCode ( ) : int

GetHashCode Method

Return a hashcode based on the Python object. This returns the hash as computed by Python, equivalent to the Python expression "hash(obj)".

GetItem ( PyObject key ) : PyObject

GetItem Method

For objects that support the Python sequence or mapping protocols, return the item at the given object index. This method raises a PythonException if the indexing operation fails.

GetItem ( int index ) : PyObject

GetItem Method

For objects that support the Python sequence or mapping protocols, return the item at the given numeric index. This method raises a PythonException if the indexing operation fails.

GetItem ( string key ) : PyObject

GetItem Method

For objects that support the Python sequence or mapping protocols, return the item at the given string index. This method raises a PythonException if the indexing operation fails.

GetIterator ( ) : PyObject

GetIterator Method

Return a new (Python) iterator for the object. This is equivalent to the Python expression "iter(object)". A PythonException will be raised if the object cannot be iterated.

GetPythonType ( ) : PyObject

GetPythonType Method

Returns the Python type of the object. This method is equivalent to the Python expression: type(object).

HasAttr ( PyObject name ) : bool

HasAttr Method

Returns true if the object has an attribute with the given name, where name is a PyObject wrapping a string or unicode object.

HasAttr ( string name ) : bool

HasAttr Method

Returns true if the object has an attribute with the given name.

Invoke ( ) : PyObject

Invoke Method

Invoke the callable object with the given arguments, passed as a PyObject[]. A PythonException is raised if the invokation fails.

Invoke ( PyObject args, PyDict kw ) : PyObject

Invoke Method

Invoke the callable object with the given positional and keyword arguments. A PythonException is raised if the invokation fails.

Invoke ( PyTuple args ) : PyObject

Invoke Method

Invoke the callable object with the given arguments, passed as a Python tuple. A PythonException is raised if the invokation fails.

Invoke ( PyTuple args, PyDict kw ) : PyObject

Invoke Method

Invoke the callable object with the given positional and keyword arguments. A PythonException is raised if the invokation fails.

InvokeMethod ( string name ) : PyObject

InvokeMethod Method

Invoke the named method of the object with the given arguments. A PythonException is raised if the invokation is unsuccessful.

InvokeMethod ( string name, PyObject args, PyDict kw ) : PyObject

InvokeMethod Method

Invoke the named method of the object with the given arguments and keyword arguments. Keyword args are passed as a PyDict object. A PythonException is raised if the invokation is unsuccessful.

InvokeMethod ( string name, PyTuple args ) : PyObject

InvokeMethod Method

Invoke the named method of the object with the given arguments. A PythonException is raised if the invokation is unsuccessful.

InvokeMethod ( string name, PyTuple args, PyDict kw ) : PyObject

InvokeMethod Method

Invoke the named method of the object with the given arguments and keyword arguments. Keyword args are passed as a PyDict object. A PythonException is raised if the invokation is unsuccessful.

IsCallable ( ) : bool

IsCallable Method

Returns true if the object is a callable object. This method always succeeds.

IsInstance ( PyObject typeOrClass ) : bool

IsInstance Method

Return true if the object is an instance of the given Python type or class. This method always succeeds.

IsIterable ( ) : bool

IsIterable Method

Returns true if the object is iterable object. This method always succeeds.

IsSubclass ( PyObject typeOrClass ) : bool

IsSubclass Method

Return true if the object is identical to or derived from the given Python type or class. This method always succeeds.

IsTrue ( ) : bool

IsTrue Method

Return true if the object is true according to Python semantics. This method always succeeds.

Length ( ) : int

Length Method

Returns the length for objects that support the Python sequence protocol, or 0 if the object does not support the protocol.

PyObject ( IntPtr ptr ) : System

PyObject Constructor

Creates a new PyObject from an IntPtr object reference. Note that the PyObject instance assumes ownership of the object reference and the reference will be DECREFed when the PyObject is garbage collected or explicitly disposed.

Repr ( ) : string

Repr Method

Return a string representation of the object. This method is the managed equivalent of the Python expression "repr(object)".

SetAttr ( PyObject name, PyObject value ) : void

SetAttr Method

Set an attribute of the object with the given name and value, where the name is a Python string or unicode object. This method throws a PythonException if the attribute set fails.

SetAttr ( string name, PyObject value ) : void

SetAttr Method

Set an attribute of the object with the given name and value. This method throws a PythonException if the attribute set fails.

SetItem ( PyObject key, PyObject value ) : void

SetItem Method

For objects that support the Python sequence or mapping protocols, set the item at the given object index to the given value. This method raises a PythonException if the set operation fails.

SetItem ( int index, PyObject value ) : void

SetItem Method

For objects that support the Python sequence or mapping protocols, set the item at the given numeric index to the given value. This method raises a PythonException if the set operation fails.

SetItem ( string key, PyObject value ) : void

SetItem Method

For objects that support the Python sequence or mapping protocols, set the item at the given string index to the given value. This method raises a PythonException if the set operation fails.

ToString ( ) : string

ToString Method

Return the string representation of the object. This method is the managed equivalent of the Python expression "str(object)".

TryBinaryOperation ( BinaryOperationBinder binder, Object arg, Object &result ) : bool
TryConvert ( ConvertBinder binder, object &result ) : bool
TryGetMember ( GetMemberBinder binder, object &result ) : bool
TryInvoke ( InvokeBinder binder, object args, object &result ) : bool
TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool
TrySetMember ( SetMemberBinder binder, object value ) : bool
TryUnaryOperation ( UnaryOperationBinder binder, Object &result ) : bool
TypeCheck ( PyObject typeOrClass ) : bool

TypeCheck Method

Returns true if the object o is of type typeOrClass or a subtype of typeOrClass.

this ( PyObject key ) : PyObject

PyObject Indexer

Provides a shorthand for the object versions of the GetItem and SetItem methods.

this ( int index ) : PyObject

Numeric Indexer

Provides a shorthand for the numeric versions of the GetItem and SetItem methods.

this ( string key ) : PyObject

String Indexer

Provides a shorthand for the string versions of the GetItem and SetItem methods.

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

Dispose Method

The Dispose method provides a way to explicitly release the Python object represented by a PyObject instance. It is a good idea to call Dispose on PyObjects that wrap resources that are limited or need strict lifetime control. Otherwise, references to Python objects will not be released until a managed garbage collection occurs.

PyObject ( ) : System

Приватные методы

Метод Описание
CheckNone ( PyObject pyObj ) : object
GetArgs ( object inargs, PyTuple &args, PyDict &kwargs ) : void

Описание методов

AsManagedObject() публичный Метод

AsManagedObject Method
Return a managed object of the given type, based on the value of the Python object.
public AsManagedObject ( Type t ) : object
t System.Type
Результат object

DelAttr() публичный Метод

DelAttr Method
Delete the named attribute of the Python object, where name is a PyObject wrapping a Python string or unicode object. This method throws a PythonException if the attribute set fails.
public DelAttr ( PyObject name ) : void
name PyObject
Результат void

DelAttr() публичный Метод

DelAttr Method
Delete the named attribute of the Python object. This method throws a PythonException if the attribute set fails.
public DelAttr ( string name ) : void
name string
Результат void

DelItem() публичный Метод

DelItem Method
For objects that support the Python sequence or mapping protocols, delete the item at the given object index. This method raises a PythonException if the delete operation fails.
public DelItem ( PyObject key ) : void
key PyObject
Результат void

DelItem() публичный Метод

DelItem Method
For objects that support the Python sequence or mapping protocols, delete the item at the given numeric index. This method raises a PythonException if the delete operation fails.
public DelItem ( int index ) : void
index int
Результат void

DelItem() публичный Метод

DelItem Method
For objects that support the Python sequence or mapping protocols, delete the item at the given string index. This method raises a PythonException if the delete operation fails.
public DelItem ( string key ) : void
key string
Результат void

Dir() публичный Метод

Dir Method
Return a list of the names of the attributes of the object. This is equivalent to the Python expression "dir(object)".
public Dir ( ) : PyList
Результат PyList

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

Dispose Method
The Dispose method provides a way to explicitly release the Python object represented by a PyObject instance. It is a good idea to call Dispose on PyObjects that wrap resources that are limited or need strict lifetime control. Otherwise, references to Python objects will not be released until a managed garbage collection occurs.
protected Dispose ( bool disposing ) : void
disposing bool
Результат void

Equals() публичный Метод

Equals Method
Return true if this object is equal to the given object. This method is based on Python equality semantics.
public Equals ( object o ) : bool
o object
Результат bool

FromManagedObject() публичный статический Метод

FromManagedObject Method
Given an arbitrary managed object, return a Python instance that reflects the managed object.
public static FromManagedObject ( object ob ) : PyObject
ob object
Результат PyObject

GetAttr() публичный Метод

GetAttr Method
Returns the named attribute of the Python object or raises a PythonException if the attribute access fails. The name argument is a PyObject wrapping a Python string or unicode object.
public GetAttr ( PyObject name ) : PyObject
name PyObject
Результат PyObject

GetAttr() публичный Метод

GetAttr Method
Returns the named attribute of the Python object, or the given default object if the attribute access fails. The name argument is a PyObject wrapping a Python string or unicode object.
public GetAttr ( PyObject name, PyObject _default ) : PyObject
name PyObject
_default PyObject
Результат PyObject

GetAttr() публичный Метод

GetAttr Method
Returns the named attribute of the Python object, or raises a PythonException if the attribute access fails.
public GetAttr ( string name ) : PyObject
name string
Результат PyObject

GetAttr() публичный Метод

GetAttr Method
Returns the named attribute of the Python object, or the given default object if the attribute access fails.
public GetAttr ( string name, PyObject _default ) : PyObject
name string
_default PyObject
Результат PyObject

GetEnumerator() публичный Метод

GetEnumerator Method
Return a new PyIter object for the object. This allows any iterable python object to be iterated over in C#. A PythonException will be raised if the object is not iterable.
public GetEnumerator ( ) : IEnumerator
Результат IEnumerator

GetHashCode() публичный Метод

GetHashCode Method
Return a hashcode based on the Python object. This returns the hash as computed by Python, equivalent to the Python expression "hash(obj)".
public GetHashCode ( ) : int
Результат int

GetItem() публичный Метод

GetItem Method
For objects that support the Python sequence or mapping protocols, return the item at the given object index. This method raises a PythonException if the indexing operation fails.
public GetItem ( PyObject key ) : PyObject
key PyObject
Результат PyObject

GetItem() публичный Метод

GetItem Method
For objects that support the Python sequence or mapping protocols, return the item at the given numeric index. This method raises a PythonException if the indexing operation fails.
public GetItem ( int index ) : PyObject
index int
Результат PyObject

GetItem() публичный Метод

GetItem Method
For objects that support the Python sequence or mapping protocols, return the item at the given string index. This method raises a PythonException if the indexing operation fails.
public GetItem ( string key ) : PyObject
key string
Результат PyObject

GetIterator() публичный Метод

GetIterator Method
Return a new (Python) iterator for the object. This is equivalent to the Python expression "iter(object)". A PythonException will be raised if the object cannot be iterated.
public GetIterator ( ) : PyObject
Результат PyObject

GetPythonType() публичный Метод

GetPythonType Method
Returns the Python type of the object. This method is equivalent to the Python expression: type(object).
public GetPythonType ( ) : PyObject
Результат PyObject

HasAttr() публичный Метод

HasAttr Method
Returns true if the object has an attribute with the given name, where name is a PyObject wrapping a string or unicode object.
public HasAttr ( PyObject name ) : bool
name PyObject
Результат bool

HasAttr() публичный Метод

HasAttr Method
Returns true if the object has an attribute with the given name.
public HasAttr ( string name ) : bool
name string
Результат bool

Invoke() публичный Метод

Invoke Method
Invoke the callable object with the given arguments, passed as a PyObject[]. A PythonException is raised if the invokation fails.
public Invoke ( ) : PyObject
Результат PyObject

Invoke() публичный Метод

Invoke Method
Invoke the callable object with the given positional and keyword arguments. A PythonException is raised if the invokation fails.
public Invoke ( PyObject args, PyDict kw ) : PyObject
args PyObject
kw PyDict
Результат PyObject

Invoke() публичный Метод

Invoke Method
Invoke the callable object with the given arguments, passed as a Python tuple. A PythonException is raised if the invokation fails.
public Invoke ( PyTuple args ) : PyObject
args PyTuple
Результат PyObject

Invoke() публичный Метод

Invoke Method
Invoke the callable object with the given positional and keyword arguments. A PythonException is raised if the invokation fails.
public Invoke ( PyTuple args, PyDict kw ) : PyObject
args PyTuple
kw PyDict
Результат PyObject

InvokeMethod() публичный Метод

InvokeMethod Method
Invoke the named method of the object with the given arguments. A PythonException is raised if the invokation is unsuccessful.
public InvokeMethod ( string name ) : PyObject
name string
Результат PyObject

InvokeMethod() публичный Метод

InvokeMethod Method
Invoke the named method of the object with the given arguments and keyword arguments. Keyword args are passed as a PyDict object. A PythonException is raised if the invokation is unsuccessful.
public InvokeMethod ( string name, PyObject args, PyDict kw ) : PyObject
name string
args PyObject
kw PyDict
Результат PyObject

InvokeMethod() публичный Метод

InvokeMethod Method
Invoke the named method of the object with the given arguments. A PythonException is raised if the invokation is unsuccessful.
public InvokeMethod ( string name, PyTuple args ) : PyObject
name string
args PyTuple
Результат PyObject

InvokeMethod() публичный Метод

InvokeMethod Method
Invoke the named method of the object with the given arguments and keyword arguments. Keyword args are passed as a PyDict object. A PythonException is raised if the invokation is unsuccessful.
public InvokeMethod ( string name, PyTuple args, PyDict kw ) : PyObject
name string
args PyTuple
kw PyDict
Результат PyObject

IsCallable() публичный Метод

IsCallable Method
Returns true if the object is a callable object. This method always succeeds.
public IsCallable ( ) : bool
Результат bool

IsInstance() публичный Метод

IsInstance Method
Return true if the object is an instance of the given Python type or class. This method always succeeds.
public IsInstance ( PyObject typeOrClass ) : bool
typeOrClass PyObject
Результат bool

IsIterable() публичный Метод

IsIterable Method
Returns true if the object is iterable object. This method always succeeds.
public IsIterable ( ) : bool
Результат bool

IsSubclass() публичный Метод

IsSubclass Method
Return true if the object is identical to or derived from the given Python type or class. This method always succeeds.
public IsSubclass ( PyObject typeOrClass ) : bool
typeOrClass PyObject
Результат bool

IsTrue() публичный Метод

IsTrue Method
Return true if the object is true according to Python semantics. This method always succeeds.
public IsTrue ( ) : bool
Результат bool

Length() публичный Метод

Length Method
Returns the length for objects that support the Python sequence protocol, or 0 if the object does not support the protocol.
public Length ( ) : int
Результат int

PyObject() защищенный Метод

protected PyObject ( ) : System
Результат System

PyObject() публичный Метод

PyObject Constructor
Creates a new PyObject from an IntPtr object reference. Note that the PyObject instance assumes ownership of the object reference and the reference will be DECREFed when the PyObject is garbage collected or explicitly disposed.
public PyObject ( IntPtr ptr ) : System
ptr System.IntPtr
Результат System

Repr() публичный Метод

Repr Method
Return a string representation of the object. This method is the managed equivalent of the Python expression "repr(object)".
public Repr ( ) : string
Результат string

SetAttr() публичный Метод

SetAttr Method
Set an attribute of the object with the given name and value, where the name is a Python string or unicode object. This method throws a PythonException if the attribute set fails.
public SetAttr ( PyObject name, PyObject value ) : void
name PyObject
value PyObject
Результат void

SetAttr() публичный Метод

SetAttr Method
Set an attribute of the object with the given name and value. This method throws a PythonException if the attribute set fails.
public SetAttr ( string name, PyObject value ) : void
name string
value PyObject
Результат void

SetItem() публичный Метод

SetItem Method
For objects that support the Python sequence or mapping protocols, set the item at the given object index to the given value. This method raises a PythonException if the set operation fails.
public SetItem ( PyObject key, PyObject value ) : void
key PyObject
value PyObject
Результат void

SetItem() публичный Метод

SetItem Method
For objects that support the Python sequence or mapping protocols, set the item at the given numeric index to the given value. This method raises a PythonException if the set operation fails.
public SetItem ( int index, PyObject value ) : void
index int
value PyObject
Результат void

SetItem() публичный Метод

SetItem Method
For objects that support the Python sequence or mapping protocols, set the item at the given string index to the given value. This method raises a PythonException if the set operation fails.
public SetItem ( string key, PyObject value ) : void
key string
value PyObject
Результат void

ToString() публичный Метод

ToString Method
Return the string representation of the object. This method is the managed equivalent of the Python expression "str(object)".
public ToString ( ) : string
Результат string

TryBinaryOperation() публичный Метод

public TryBinaryOperation ( BinaryOperationBinder binder, Object arg, Object &result ) : bool
binder BinaryOperationBinder
arg Object
result Object
Результат bool

TryConvert() публичный Метод

public TryConvert ( ConvertBinder binder, object &result ) : bool
binder ConvertBinder
result object
Результат bool

TryGetMember() публичный Метод

public TryGetMember ( GetMemberBinder binder, object &result ) : bool
binder GetMemberBinder
result object
Результат bool

TryInvoke() публичный Метод

public TryInvoke ( InvokeBinder binder, object args, object &result ) : bool
binder InvokeBinder
args object
result object
Результат bool

TryInvokeMember() публичный Метод

public TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool
binder InvokeMemberBinder
args object
result object
Результат bool

TrySetMember() публичный Метод

public TrySetMember ( SetMemberBinder binder, object value ) : bool
binder SetMemberBinder
value object
Результат bool

TryUnaryOperation() публичный Метод

public TryUnaryOperation ( UnaryOperationBinder binder, Object &result ) : bool
binder UnaryOperationBinder
result Object
Результат bool

TypeCheck() публичный Метод

TypeCheck Method
Returns true if the object o is of type typeOrClass or a subtype of typeOrClass.
public TypeCheck ( PyObject typeOrClass ) : bool
typeOrClass PyObject
Результат bool

this() публичный Метод

PyObject Indexer
Provides a shorthand for the object versions of the GetItem and SetItem methods.
public this ( PyObject key ) : PyObject
key PyObject
Результат PyObject

this() публичный Метод

Numeric Indexer
Provides a shorthand for the numeric versions of the GetItem and SetItem methods.
public this ( int index ) : PyObject
index int
Результат PyObject

this() публичный Метод

String Indexer
Provides a shorthand for the string versions of the GetItem and SetItem methods.
public this ( string key ) : PyObject
key string
Результат PyObject

Описание свойств

obj защищенное свойство

protected IntPtr obj
Результат IntPtr