class
Crython::PyObject
- Crython::PyObject
- Reference
- Object
Overview
Extension methods for PyObject
Included Modules
- Crython::ObjectProtocol
Defined in:
crython/py2cr/basic.crcrython/py2cr/collections.cr
crython/pyobject.cr
Constructors
-
.from_borrowed(raw : LibPython::PyObject) : PyObject
Promote a borrowed reference before its owner can be released.
-
.from_owned(raw : LibPython::PyObject) : PyObject
Adopt a new reference returned by a CPython API.
Macro Summary
-
method_missing(call)
Convenience syntax for simple Python method calls.
Instance Method Summary
- #!=(other : PyObject) : PyObject
-
#!=(other) : PyObject
Returns
trueif this object is not equal to other. - #%(other : PyObject) : PyObject
- #%(other) : PyObject
- #*(other : PyObject) : PyObject
- #*(other) : PyObject
- #**(other : PyObject) : PyObject
- #**(other) : PyObject
- #+(other : PyObject) : PyObject
- #+(other) : PyObject
- #-(other : PyObject) : PyObject
- #-(other) : PyObject
- #/(other : PyObject) : PyObject
- #/(other) : PyObject
- #//(other : PyObject) : PyObject
- #//(other) : PyObject
- #<(other : PyObject) : PyObject
- #<(other) : PyObject
- #<=(other : PyObject) : PyObject
- #<=(other) : PyObject
- #==(other : PyObject) : PyObject
-
#==(other) : PyObject
Returns
false(other can only be aValuehere). - #>(other : PyObject) : PyObject
- #>(other) : PyObject
- #>=(other : PyObject) : PyObject
- #>=(other) : PyObject
- #[](*key) : PyObject
- #[]=(key, value) : Nil
-
#call(call : String | Symbol, *args, **kwargs) : PyObject
Reliable public API for Python attribute lookup and invocation.
- #call?(call : String | Symbol, *args, **kwargs) : PyObject | Nil
- #finalize
-
#get_type_name : String
Helper method to get Python object type name
- #inspect(io) : Nil
-
#invoke(*args, **kwargs) : PyObject
Invoke this object itself when it is callable.
-
#raw : Pointer(Void)
Access the raw Python object pointer
-
#to_a(element_type : T.class) : Array(T) forall T
Convert to Crystal Array
-
#to_b : Bool
Convert to Crystal Bool
-
#to_complex : Complex
Convert Python complex to Crystal Complex
-
#to_cr
Convert to an appropriate Crystal type, accepting Python subclasses.
-
#to_dict : Hash(PyObject, PyObject)
Convert Python dict to Crystal Hash(PyObject, PyObject)
-
#to_f64 : Float64
Convert to Crystal Float64
-
#to_h(key_type : K.class, value_type : V.class) : Hash(K, V) forall K, V
Convert to Crystal Hash
-
#to_i32 : Int32
Convert to Crystal Int32
-
#to_i64 : Int64
Convert to Crystal Int64
-
#to_list : Array(PyObject)
Convert Python list to Crystal Array(PyObject)
- #to_py : PyObject
-
#to_s(io : IO) : Nil
Convert to Crystal String
- #to_s(io) : Nil
-
#to_tuple : Array(PyObject)
Convert Python tuple to Crystal Array(PyObject)
Instance methods inherited from module Crython::ObjectProtocol
<=>(other : ObjectProtocol)
<=>,
attr(attr : String) : PyObject
attr,
attr?(attr : String) : PyObject | Nil
attr?,
callable? : Bool
callable?,
del_attr(attr : String) : Bool
del_attr,
has_attr?(attr : String) : Bool
has_attr?,
set_attr(attr : String, obj : ObjectMethods)
set_attr,
to_unsafe
to_unsafe
Constructor Detail
Promote a borrowed reference before its owner can be released.
Adopt a new reference returned by a CPython API.
Macro Detail
Convenience syntax for simple Python method calls.
For uppercase attribute names or other complex call sites, prefer
obj.call("Name", ...) because Crystal method syntax is stricter
than Python attribute syntax.
Instance Method Detail
Returns true if this object is not equal to other.
By default this method is implemented as !(self == other)
so there's no need to override this unless there's a more efficient
way to do it.
Returns false (other can only be a Value here).
Reliable public API for Python attribute lookup and invocation.
Use this when the Python attribute name is not a natural Crystal
method name, such as class constructors like Counter.
Invoke this object itself when it is callable.
Convert Python dict to Crystal Hash(PyObject, PyObject)
Convert to Crystal Hash