Package org.python.core
Class PyObject
java.lang.Object
org.python.core.PyObject
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
_codecs.EncodingMap
,_hashlib.Hash
,_marshal.Marshaller
,_marshal.Unmarshaller
,AbstractDict
,AbstractReference
,BaseDictionaryView
,BasePointer
,BaseSet
,ByReference
,CData
,Condition
,CType
,dict_builder
,DynamicLibrary
,Encoder
,exceptions
,FieldNameIterator
,importer
,JavaImporter
,Lock
,MarkupIterator
,MatchObject
,operator
,PatternObject
,PyBaseException
,PyBeanEvent
,PyBeanEventProperty
,PyBuiltinCallable
,PyBZ2Compressor
,PyBZ2Decompressor
,PyBZ2File
,PyCell
,PyClass
,PyClassMethod
,PyCode
,PyComplex
,PyCompoundCallable
,PyConnection
,PyCursor
,PyDeque
,PyDescriptor
,PyDialect
,PyDictProxy
,PyFile
,PyFileReader
,PyFileWriter
,PyFloat
,PyFrame
,PyFunction
,PyInstance
,PyInteger
,PyIOBase
,PyIterator
,PyJavaPackage
,PyLocal
,PyLock
,PyLong
,PyMethod
,PyModule
,PyNone
,PyNullImporter
,PyObjectDerived
,PyPartial
,PyProperty
,PyRandom
,PyReflectedField
,PyReflectedFunction
,PySequence
,PySingleton
,PySlice
,PyStatement
,PyStaticMethod
,PyStruct
,PySuper
,PySystemState
,PyTraceback
,PyType
,PyWriter
,RLock
,Scanner
,ScannerObject
,set_builder
,StructLayout.Field
,synchronize.SynchronizedCallable
,zxJDBC
All objects known to the Jython runtime system are represented by an instance of the class
PyObject
or one of its subclasses.- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription__abs__()
Equivalent to the standard Python __abs__ method.Equivalent to the standard Python __add__ method.Equivalent to the standard Python __and__ method__call__()
A variant of the __call__ method with no arguments.A variant of the __call__ method with one argument.A variant of the __call__ method when no keywords are passed.The basic method to override when implementing a callable object.A variant of the __call__ method with two arguments.A variant of the __call__ method with one extra initial argument.A variant of the __call__ method with three arguments.A variant of the __call__ method with four arguments.__call__
(ThreadState state) __call__
(ThreadState state, PyObject arg0) __call__
(ThreadState state, PyObject[] args) __call__
(ThreadState state, PyObject[] args, String[] keywords) __call__
(ThreadState state, PyObject arg0, PyObject arg1) __call__
(ThreadState state, PyObject arg1, PyObject[] args, String[] keywords) __call__
(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2) int
Equivalent to the standard Python __cmp__ method.final PyObject
__coerce__
(PyObject pyo) Equivalent to the standard Python __coerce__ method.Implements numeric coercionEquivalent to the standard Python __complex__ method.boolean
Equivalent to the standard Python __contains__ method.void
__delattr__
(String name) A variant of the __delattr__ method which accepts a String as the key.final void
__delattr__
(PyString name) Equivalent to the standard Python __delattr__ method.void
__delete__
(PyObject obj) void
__delitem__
(String key) A variant of the __delitem__ method which accepts a String as the key.void
__delitem__
(PyObject key) Equivalent to the standard Python __delitem__ method.void
__delslice__
(PyObject start, PyObject stop) void
__delslice__
(PyObject s_start, PyObject s_stop, PyObject s_step) __dir__()
Equivalent to the standard Python __dir__ method.Equivalent to the standard Python __div__ method__divmod__
(PyObject other) Equivalent to the standard Python __divmod__ methodvoid
PyObjects that implementorg.python.core.finalization.HasFinalizeTrigger
shall implement this method via:
FinalizeTrigger.ensureFinalizer(this);
Equivalent to the standard Python __eq__ method.final PyObject
__findattr__
(String name) A variant of the __findattr__ method which accepts a JavaString
as the name.final PyObject
__findattr__
(PyString name) Very similar to the standard Python __getattr__ method.__findattr_ex__
(String name) Attribute lookup hook.__finditem__
(int key) A variant of the __finditem__ method which accepts a primitiveint
as the key.__finditem__
(String key) A variant of the __finditem__ method which accepts a JavaString
as the key.__finditem__
(PyObject key) Very similar to the standard Python __getitem__ method.Equivalent to the standard Python __float__ method.__floordiv__
(PyObject other) Equivalent to the standard Python __floordiv__ method__format__
(PyObject formatSpec) Equivalent to the standard Python __ge__ method.Get descriptor for this PyObject.final PyObject
__getattr__
(String name) A variant of the __getattr__ method which accepts a JavaString
as the name.final PyObject
__getattr__
(PyString name) Equivalent to the standard Python __getattr__ method.__getitem__
(int key) Equivalent to the standard Python __getitem__ method.__getitem__
(PyObject key) Equivalent to the standard Python __getitem__ method.__getslice__
(PyObject start, PyObject stop) __getslice__
(PyObject s_start, PyObject s_stop, PyObject s_step) Equivalent to the standard Python __gt__ method.final PyInteger
__hash__()
Equivalent to the standard Python __hash__ method.__hex__()
Equivalent to the standard Python __hex__ method Should only be overridden by numeric objects that can be reasonably represented as a hexadecimal string.Equivalent to the standard Python __iadd__ method.Equivalent to the standard Python __iand__ methodEquivalent to the standard Python __idiv__ method__idivmod__
(PyObject other) Equivalent to the standard Python __idivmod__ method__ifloordiv__
(PyObject other) Equivalent to the standard Python __ifloordiv__ method__ilshift__
(PyObject other) Equivalent to the standard Python __ilshift__ methodEquivalent to the standard Python __imod__ methodEquivalent to the standard Python __imul__ method.Equivalent to the standard Python __index__ method.__int__()
Equivalent to the standard Python __int__ method.Equivalent to the standard Python __invert__ method.Equivalent to the standard Python __ior__ methodEquivalent to the standard Python __ipow__ method__irshift__
(PyObject other) Equivalent to the standard Python __irshift__ methodEquivalent to the standard Python __isub__ method__iter__()
Return an iterator that is used to iterate the element of this sequence.Return the next element of the sequence that this is an iterator for.__itruediv__
(PyObject other) Equivalent to the standard Python __itruediv__ methodEquivalent to the standard Python __ixor__ methodEquivalent to the standard Python __le__ method.int
__len__()
Equivalent to the standard Python __len__ method.__long__()
Equivalent to the standard Python __long__ method.__lshift__
(PyObject other) Equivalent to the standard Python __lshift__ methodEquivalent to the standard Python __lt__ method.Equivalent to the standard Python __mod__ methodEquivalent to the standard Python __mul__ method.Equivalent to the standard Python __ne__ method.__neg__()
Equivalent to the standard Python __neg__ method.boolean
Equivalent to the standard Python __nonzero__ method.__not__()
Implements boolean not__oct__()
Equivalent to the standard Python __oct__ method.Equivalent to the standard Python __or__ method__pos__()
Equivalent to the standard Python __pos__ method.Equivalent to the standard Python __pow__ methodImplements the three argument power function.Equivalent to the standard Python __radd__ method.Equivalent to the standard Python __rand__ methodEquivalent to the standard Python __rdiv__ method__rdivmod__
(PyObject other) Equivalent to the standard Python __rdivmod__ methodUsed for pickling.__reduce_ex__
(int arg) Used for pickling.__repr__()
Equivalent to the standard Python__repr__
method.__rfloordiv__
(PyObject other) Equivalent to the standard Python __rfloordiv__ method__rlshift__
(PyObject other) Equivalent to the standard Python __rlshift__ methodEquivalent to the standard Python __rmod__ methodEquivalent to the standard Python __rmul__ method.Equivalent to the standard Python __ror__ methodEquivalent to the standard Python __rpow__ method__rrshift__
(PyObject other) Equivalent to the standard Python __rrshift__ method__rshift__
(PyObject other) Equivalent to the standard Python __rshift__ methodEquivalent to the standard Python __rsub__ method__rtruediv__
(PyObject other) Equivalent to the standard Python __rtruediv__ methodEquivalent to the standard Python __rxor__ methodvoid
void
__setattr__
(String name, PyObject value) A variant of the __setattr__ method which accepts a String as the key.final void
__setattr__
(PyString name, PyObject value) Equivalent to the standard Python __setattr__ method.void
__setitem__
(int key, PyObject value) A variant of the __setitem__ method which accepts a primitiveint
as the key.void
__setitem__
(String key, PyObject value) A variant of the __setitem__ method which accepts a String as the key.void
__setitem__
(PyObject key, PyObject value) Equivalent to the standard Python __setitem__ method.void
__setslice__
(PyObject start, PyObject stop, PyObject value) void
__setslice__
(PyObject s_start, PyObject s_stop, PyObject s_step, PyObject value) __str__()
Equivalent to the standard Python __str__ method.Equivalent to the standard Python __sub__ method__tojava__
(Class<?> c) Equivalent to the Jython __tojava__ method.__truediv__
(PyObject other) Equivalent to the standard Python __truediv__ methodEquivalent to the standard Python __trunc__ method.Equivalent to the standard Python __xor__ methodfinal PyObject
Implements the Python expressionthis + o2
.final PyObject
Implements the Python expressionthis & o2
_callextra
(PyObject[] args, String[] keywords, PyObject starargs, PyObject kwargs) final int
Implements cmp(this, other)final PyObject
Implements the Python expressionthis / o2
final PyObject
Implements the Python expressionthis divmod o2
boolean
final PyObject
Implements the Python expressionthis == other
.final PyObject
Implements the Python expressionthis // o2
final PyObject
Implements the Python expressionthis >= other
.final PyObject
Implements the Python expressionthis > other
.final PyObject
Implements the Python expressionthis += o2
.final PyObject
Implements the Python expressionthis &= o2
final PyObject
Implements the Python expressionthis /= o2
final PyObject
Implements the Python expressionthis divmod= o2
final PyObject
_ifloordiv
(PyObject o2) Implements the Python expressionthis //= o2
final PyObject
Implements the Python expressionthis <<= o2
final PyObject
Implements the Python expressionthis %= o2
final PyObject
Implements the Python expressionthis *= o2
.final PyObject
Implementsin
operator.final PyObject
Implements the Python expressionthis |= o2
final PyObject
Implements the Python expressionthis **= o2
final PyObject
Implements the Python expressionthis >>= o2
Implementsis
operator.Implementsis not
operator.final PyObject
Implements the Python expressionthis -= o2
final PyObject
Implements the Python expressionthis /= o2
final PyObject
Implements the Python expressionthis ^= o2
A convenience function for PyProxys.void
final PyObject
Implements the Python expressionthis <= other
.final PyObject
Implements the Python expressionthis << o2
final PyObject
Implements the Python expressionthis < other
.final PyObject
Implements the Python expressionthis % o2
final PyObject
Implements the Python expressionthis * o2
.final PyObject
Implements the Python expressionthis != other
.final PyObject
Implementsnot in
operator.final PyObject
Implements the Python expressionthis | o2
final PyObject
Implements the Python expressionthis ** o2
final PyObject
Implements the Python expressionthis >> o2
final PyObject
Implements the Python expressionthis - o2
final PyObject
Implements the Python expressionthis / o2
final PyObject
Implements the Python expressionthis ^ o2
double
asDouble()
Convert this object into a double.int
asIndex()
Convert this object into an index-sized integer.int
Convert this object into an index-sized integer.int
asInt()
Convert this object into an int.int
asInt
(int index) Returns an Iterable over the Python iterator returned by __iter__ on this object.long
asLong()
Convert this object into a long.long
asLong
(int index) asName
(int index) static final String
asString()
asString
(int index) asStringOrNull
(int index) int
Equivalent to the standard Python bit_length method.Equivalent to the standard Python conjugate method.void
delDict()
void
delType()
void
dispatch__init__
(PyObject[] args, String[] keywords) Dispatch __init__ behaviorboolean
Should almost never be overridden.xxx implements where meaningfulgetDict()
xxx implements where meaningfulgetType()
int
hashCode()
boolean
boolean
boolean
Shortcut for calling a method on a PyObject with no args.Shortcut for calling a method on a PyObject with one arg.Shortcut for calling a method on a PyObject from Java.Shortcut for calling a method on a PyObject with two args.Shortcut for calling a method on a PyObject with one extra initial argument.boolean
boolean
boolean
isIndex()
Determine if this object can act as an index (implements __index__).boolean
Determine if this object can act as an int (implements __int__).boolean
boolean
boolean
void
noAttributeError
(String name) static PyObject
object___subclasshook__
(PyType type, PyObject subclass) void
readonlyAttributeError
(String name) void
void
toString()
-
Field Details
-
TYPE
-
gcMonitorGlobal
public static boolean gcMonitorGlobalThis should have been suited atgc
, but that would cause a dependency cycle in the init-phases ofgc.class
andPyObject.class
. Now this boolean mirrors the presence of thegc.MONITOR_GLOBAL
-flag in Jython's gc module.
Do not change manually.
-
-
Constructor Details
-
PyObject
-
PyObject
public PyObject()The standard constructor for aPyObject
. It will set theobjtype
field to correspond to the specific subclass ofPyObject
being instantiated.
-
-
Method Details
-
getType
-
setType
-
delType
public void delType() -
fastGetClass
-
dispatch__init__
Dispatch __init__ behavior -
__repr__
Equivalent to the standard Python__repr__
method. Each sub-class ofPyObject
is likely to re-define this method to provide for its own reproduction. -
toString
-
__str__
Equivalent to the standard Python __str__ method. The default implementation (inPyObject
) calls__repr__()
, making it unnecessary to override__str__
in sub-classes ofPyObject
where both forms are the same. A common choice is to provide the same implementation to__str__
andtoString
, for consistency in the printed form of objects between Python and Java. -
__ensure_finalizer__
public void __ensure_finalizer__()PyObjects that implementorg.python.core.finalization.HasFinalizeTrigger
shall implement this method via:
FinalizeTrigger.ensureFinalizer(this);
-
__unicode__
-
__hash__
Equivalent to the standard Python __hash__ method. This method can not be overridden. Instead, you should override the standard JavahashCode
method to return an appropriate hash code for thePyObject
. -
hashCode
public int hashCode() -
equals
Should almost never be overridden. If overridden, it is the subclasses responsibility to ensure thata.equals(b) == true
iffcmp(a,b) == 0
-
__nonzero__
public boolean __nonzero__()Equivalent to the standard Python __nonzero__ method. Returns whether of not a givenPyObject
is considered true. -
__tojava__
Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special objectPy.NoConversion
if thisPyObject
can not be converted to the desired Java class.- Parameters:
c
- the Class to convert thisPyObject
to.
-
__call__
The basic method to override when implementing a callable object. The first len(args)-len(keywords) members of args[] are plain arguments. The last len(keywords) arguments are the values of the keyword arguments.- Parameters:
args
- all arguments to the function (including keyword arguments).keywords
- the keywords used for all keyword arguments.
-
__call__
-
__call__
A variant of the __call__ method with one extra initial argument. This variant is used to allow method invocations to be performed efficiently. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
arg1
- the first argument to the function.args
- the last arguments to the function (including keyword arguments).keywords
- the keywords used for all keyword arguments.
-
__call__
-
__call__
A variant of the __call__ method when no keywords are passed. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
args
- all arguments to the function.
-
__call__
-
__call__
A variant of the __call__ method with no arguments. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance. -
__call__
-
__call__
A variant of the __call__ method with one argument. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
arg0
- the single argument to the function.
-
__call__
-
__call__
A variant of the __call__ method with two arguments. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
arg0
- the first argument to the function.arg1
- the second argument to the function.
-
__call__
-
__call__
A variant of the __call__ method with three arguments. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
arg0
- the first argument to the function.arg1
- the second argument to the function.arg2
- the third argument to the function.
-
__call__
-
__call__
A variant of the __call__ method with four arguments. The default behavior is to invoke__call__(args, keywords)
with the appropriate arguments. The only reason to override this function would be for improved performance.- Parameters:
arg0
- the first argument to the function.arg1
- the second argument to the function.arg2
- the third argument to the function.arg3
- the fourth argument to the function.
-
__call__
-
_callextra
-
isCallable
public boolean isCallable() -
isNumberType
public boolean isNumberType() -
isMappingType
public boolean isMappingType() -
isSequenceType
public boolean isSequenceType() -
isInteger
public boolean isInteger()Determine if this object can act as an int (implements __int__).- Returns:
- true if the object can act as an int
-
isIndex
public boolean isIndex()Determine if this object can act as an index (implements __index__).- Returns:
- true if the object can act as an index
-
__len__
public int __len__()Equivalent to the standard Python __len__ method. Part of the mapping discipline.- Returns:
- the length of the object
-
__finditem__
Very similar to the standard Python __getitem__ method. Instead of throwing a KeyError if the item isn't found, this just returns null. Classes that wish to implement __getitem__ should override this method instead (with the appropriate semantics.- Parameters:
key
- the key to lookup in this container- Returns:
- the value corresponding to key or null if key is not found
-
__finditem__
A variant of the __finditem__ method which accepts a primitiveint
as the key. By default, this method will call__finditem__(PyObject key)
with the appropriate args. The only reason to override this method is for performance.- Parameters:
key
- the key to lookup in this sequence.- Returns:
- the value corresponding to key or null if key is not found.
- See Also:
-
__finditem__
A variant of the __finditem__ method which accepts a JavaString
as the key. By default, this method will call__finditem__(PyObject key)
with the appropriate args. The only reason to override this method is for performance. Warning: key must be an interned string!!!!!!!!- Parameters:
key
- the key to lookup in this sequence - must be an interned string .- Returns:
- the value corresponding to key or null if key is not found.
- See Also:
-
__getitem__
Equivalent to the standard Python __getitem__ method. This variant takes a primitiveint
as the key. This method should not be overridden. Override the__finditem__
method instead.- Parameters:
key
- the key to lookup in this container.- Returns:
- the value corresponding to that key.
- Throws:
PyException
-KeyError
if the key is not found.- See Also:
-
__getitem__
Equivalent to the standard Python __getitem__ method. This method should not be overridden. Override the__finditem__
method instead.- Parameters:
key
- the key to lookup in this container.- Returns:
- the value corresponding to that key.
- Throws:
PyException
-KeyError
if the key is not found.- See Also:
-
__setitem__
Equivalent to the standard Python __setitem__ method.- Parameters:
key
- the key whose value will be setvalue
- the value to set this key to
-
__setitem__
A variant of the __setitem__ method which accepts a String as the key. This String must be interned. By default, this will call__setitem__(PyObject key, PyObject value)
with the appropriate args. The only reason to override this method is for performance.- Parameters:
key
- the key whose value will be set - must be an interned string .value
- the value to set this key to- See Also:
-
__setitem__
A variant of the __setitem__ method which accepts a primitiveint
as the key. By default, this will call__setitem__(PyObject key, PyObject value)
with the appropriate args. The only reason to override this method is for performance.- Parameters:
key
- the key whose value will be setvalue
- the value to set this key to- See Also:
-
__delitem__
Equivalent to the standard Python __delitem__ method.- Parameters:
key
- the key to be removed from the container- Throws:
PyException
-KeyError
if the key is not found in the container
-
__delitem__
A variant of the __delitem__ method which accepts a String as the key. This String must be interned. By default, this will call__delitem__(PyObject key)
with the appropriate args. The only reason to override this method is for performance.- Parameters:
key
- the key who will be removed - must be an interned string .- Throws:
PyException
-KeyError
if the key is not found in the container- See Also:
-
__getslice__
-
__setslice__
-
__delslice__
-
__getslice__
-
__setslice__
-
__delslice__
-
__iter__
Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:
public PyObject __iter__() { return new PySequenceIter(this); }
When iterating over a python sequence from java code, it should be done with code like this:for (PyObject item : seq.asIterable()) { // Do something with item }
- Since:
- 2.2
-
asIterable
Returns an Iterable over the Python iterator returned by __iter__ on this object. If this object doesn't support __iter__, a TypeException will be raised when iterator is called on the returned Iterable. -
__iternext__
Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.- Since:
- 2.2
-
__findattr__
Very similar to the standard Python __getattr__ method. Instead of throwing a AttributeError if the item isn't found, this just returns null. By default, this method will call__findattr__(name.internedString)
with the appropriate args.- Parameters:
name
- the name to lookup in this namespace- Returns:
- the value corresponding to name or null if name is not found
-
__findattr__
A variant of the __findattr__ method which accepts a JavaString
as the name. Warning: name must be an interned string!- Parameters:
name
- the name to lookup in this namespace must be an interned string.- Returns:
- the value corresponding to name or null if name is not found
-
__findattr_ex__
Attribute lookup hook. If the attribute is not found, null may be returned or a Py.AttributeError can be thrown, whatever is more correct, efficient and/or convenient for the implementing class. Client code should use__getattr__(String)
or__findattr__(String)
. Both methods have a clear policy for failed lookups.- Returns:
- The looked up value. May return null if the attribute is not found
- Throws:
PyException
-AttributeError
if the attribute is not found. This is not mandatory, null can be returned if it fits the implementation better, or for performance reasons.
-
__getattr__
Equivalent to the standard Python __getattr__ method. By default, this method will call__getattr__(name.internedString)
with the appropriate args.- Parameters:
name
- the name to lookup in this namespace- Returns:
- the value corresponding to name
- Throws:
PyException
-AttributeError
if the name is not found.- See Also:
-
__getattr__
A variant of the __getattr__ method which accepts a JavaString
as the name. This method can not be overridden. Override the__findattr_ex__
method instead. Warning: name must be an interned string!!!!!!!!- Parameters:
name
- the name to lookup in this namespace must be an interned string .- Returns:
- the value corresponding to name
- Throws:
PyException
-AttributeError
if the name is not found.- See Also:
-
noAttributeError
-
readonlyAttributeError
-
__setattr__
Equivalent to the standard Python __setattr__ method. This method can not be overridden.- Parameters:
name
- the name to lookup in this namespace- Throws:
PyException
-AttributeError
if the name is not found.- See Also:
-
__setattr__
A variant of the __setattr__ method which accepts a String as the key. This String must be interned.- Parameters:
name
- the name whose value will be set - must be an interned string .value
- the value to set this name to- See Also:
-
__delattr__
Equivalent to the standard Python __delattr__ method. This method can not be overridden.- Parameters:
name
- the name to which will be removed- Throws:
PyException
-AttributeError
if the name doesn't exist- See Also:
-
__delattr__
A variant of the __delattr__ method which accepts a String as the key. This String must be interned. By default, this will call__delattr__(PyString name)
with the appropriate args. The only reason to override this method is for performance.- Parameters:
name
- the name which will be removed - must be an interned string .- Throws:
PyException
-AttributeError
if the name doesn't exist- See Also:
-
__dir__
Equivalent to the standard Python __dir__ method.- Returns:
- a list of names defined by this object.
-
_doget
-
_doget
-
_doset
-
__coerce_ex__
Implements numeric coercion- Parameters:
o
- the other object involved in the coercion- Returns:
- null if coercion is not implemented Py.None if coercion was not possible a single PyObject to use to replace o if this is unchanged; or a PyObject[2] consisting of replacements for this and o.
-
__coerce__
Equivalent to the standard Python __coerce__ method. This method can not be overridden. To implement __coerce__ functionality, override __coerce_ex__ instead. Also, do not call this method from exposed 'coerce' methods. Instead, Use adaptToCoerceTuple over the result of the overridden __coerce_ex__.- Parameters:
pyo
- the other object involved in the coercion.- Returns:
- a tuple of this object and pyo coerced to the same type or Py.NotImplemented if no coercion is possible.
- See Also:
-
__cmp__
Equivalent to the standard Python __cmp__ method.- Parameters:
other
- the object to compare this with.- Returns:
- -1 if
this<o
; 0 ifthis==o
; +1 ifthis>o
; -2 if no comparison is implemented
-
__eq__
Equivalent to the standard Python __eq__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__ne__
Equivalent to the standard Python __ne__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__le__
Equivalent to the standard Python __le__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__lt__
Equivalent to the standard Python __lt__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__ge__
Equivalent to the standard Python __ge__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__gt__
Equivalent to the standard Python __gt__ method.- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
_cmp
Implements cmp(this, other)- Parameters:
o
- the object to compare this with.- Returns:
- -1 if
this<0
; 0 ifthis==o
; +1 ifthis>o
-
_eq
Implements the Python expressionthis == other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_ne
Implements the Python expressionthis != other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_le
Implements the Python expressionthis <= other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_lt
Implements the Python expressionthis < other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_ge
Implements the Python expressionthis >= other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_gt
Implements the Python expressionthis > other
.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_is
Implementsis
operator.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_isnot
Implementsis not
operator.- Parameters:
o
- the object to compare this with.- Returns:
- the result of the comparison
-
_in
Implementsin
operator.- Parameters:
o
- the container to search for this element.- Returns:
- the result of the search.
-
_notin
Implementsnot in
operator.- Parameters:
o
- the container to search for this element.- Returns:
- the result of the search.
-
__contains__
Equivalent to the standard Python __contains__ method.- Parameters:
o
- the element to search for in this container.- Returns:
- the result of the search.
-
__format__
-
__not__
Implements boolean not- Returns:
- not this.
-
__hex__
Equivalent to the standard Python __hex__ method Should only be overridden by numeric objects that can be reasonably represented as a hexadecimal string.- Returns:
- a string representing this object as a hexadecimal number.
-
__oct__
Equivalent to the standard Python __oct__ method. Should only be overridden by numeric objects that can be reasonably represented as an octal string.- Returns:
- a string representing this object as an octal number.
-
__int__
Equivalent to the standard Python __int__ method. Should only be overridden by numeric objects that can be reasonably coerced into an integer.- Returns:
- an integer corresponding to the value of this object.
-
__long__
Equivalent to the standard Python __long__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python long.- Returns:
- a PyLong or PyInteger corresponding to the value of this object.
-
__float__
Equivalent to the standard Python __float__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python float.- Returns:
- a float corresponding to the value of this object.
-
__complex__
Equivalent to the standard Python __complex__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python complex number.- Returns:
- a complex number corresponding to the value of this object.
-
__trunc__
Equivalent to the standard Python __trunc__ method. Should only be overridden by numeric objects that can reasonably be truncated to an Integral.- Returns:
- the Integral closest to x between 0 and x.
-
conjugate
Equivalent to the standard Python conjugate method. Should only be overridden by numeric objects that can calculate a complex conjugate.- Returns:
- the complex conjugate.
-
bit_length
public int bit_length()Equivalent to the standard Python bit_length method. Should only be overridden by numeric objects that can calculate a bit_length.- Returns:
- the bit_length of this object.
-
__pos__
Equivalent to the standard Python __pos__ method.- Returns:
- +this.
-
__neg__
Equivalent to the standard Python __neg__ method.- Returns:
- -this.
-
__abs__
Equivalent to the standard Python __abs__ method.- Returns:
- abs(this).
-
__invert__
Equivalent to the standard Python __invert__ method.- Returns:
- ~this.
-
__index__
Equivalent to the standard Python __index__ method.- Returns:
- a PyInteger or PyLong
- Throws:
PyException
-TypeError
if not supported
-
__pow__
Implements the three argument power function.- Parameters:
o2
- the power to raise this number to.o3
- the modulus to perform this operation in or null if no modulo is to be used- Returns:
- this object raised to the given power in the given modulus
-
__add__
Equivalent to the standard Python __add__ method.- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the add, or null if this operation is not defined.
-
__radd__
Equivalent to the standard Python __radd__ method.- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the add, or null if this operation is not defined.
-
__iadd__
Equivalent to the standard Python __iadd__ method.- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the iadd, or null if this operation is not defined
-
_add
Implements the Python expressionthis + o2
.- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the add.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_iadd
Implements the Python expressionthis += o2
.- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the iadd.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__sub__
Equivalent to the standard Python __sub__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the sub, or null if this operation is not defined
-
__rsub__
Equivalent to the standard Python __rsub__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the sub, or null if this operation is not defined.
-
__isub__
Equivalent to the standard Python __isub__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the isub, or null if this operation is not defined
-
_sub
Implements the Python expressionthis - o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the sub.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_isub
Implements the Python expressionthis -= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the isub.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__mul__
Equivalent to the standard Python __mul__ method.- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the mul, or null if this operation is not defined
-
__rmul__
Equivalent to the standard Python __rmul__ method.- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the mul, or null if this operation is not defined.
-
__imul__
Equivalent to the standard Python __imul__ method.- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the imul, or null if this operation is not defined.
-
_mul
Implements the Python expressionthis * o2
.- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the mul.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_imul
Implements the Python expressionthis *= o2
.- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the imul.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__div__
Equivalent to the standard Python __div__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the div, or null if this operation is not defined
-
__rdiv__
Equivalent to the standard Python __rdiv__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the div, or null if this operation is not defined.
-
__idiv__
Equivalent to the standard Python __idiv__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the idiv, or null if this operation is not defined
-
_div
Implements the Python expressionthis / o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the div.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_idiv
Implements the Python expressionthis /= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the idiv.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__floordiv__
Equivalent to the standard Python __floordiv__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the floordiv, or null if this operation is not defined
-
__rfloordiv__
Equivalent to the standard Python __rfloordiv__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the floordiv, or null if this operation is not defined.
-
__ifloordiv__
Equivalent to the standard Python __ifloordiv__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the ifloordiv, or null if this operation is not defined
-
_floordiv
Implements the Python expressionthis // o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the floordiv.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_ifloordiv
Implements the Python expressionthis //= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the ifloordiv.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__truediv__
Equivalent to the standard Python __truediv__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the truediv, or null if this operation is not defined
-
__rtruediv__
Equivalent to the standard Python __rtruediv__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the truediv, or null if this operation is not defined.
-
__itruediv__
Equivalent to the standard Python __itruediv__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the itruediv, or null if this operation is not defined
-
_truediv
Implements the Python expressionthis / o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the truediv.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_itruediv
Implements the Python expressionthis /= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the itruediv.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__mod__
Equivalent to the standard Python __mod__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the mod, or null if this operation is not defined
-
__rmod__
Equivalent to the standard Python __rmod__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the mod, or null if this operation is not defined.
-
__imod__
Equivalent to the standard Python __imod__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the imod, or null if this operation is not defined
-
_mod
Implements the Python expressionthis % o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the mod.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_imod
Implements the Python expressionthis %= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the imod.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__divmod__
Equivalent to the standard Python __divmod__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the divmod, or null if this operation is not defined
-
__rdivmod__
Equivalent to the standard Python __rdivmod__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the divmod, or null if this operation is not defined.
-
__idivmod__
Equivalent to the standard Python __idivmod__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the idivmod, or null if this operation is not defined
-
_divmod
Implements the Python expressionthis divmod o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the divmod.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_idivmod
Implements the Python expressionthis divmod= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the idivmod.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__pow__
Equivalent to the standard Python __pow__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the pow, or null if this operation is not defined
-
__rpow__
Equivalent to the standard Python __rpow__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the pow, or null if this operation is not defined.
-
__ipow__
Equivalent to the standard Python __ipow__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the ipow, or null if this operation is not defined
-
_pow
Implements the Python expressionthis ** o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the pow.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_ipow
Implements the Python expressionthis **= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the ipow.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__lshift__
Equivalent to the standard Python __lshift__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the lshift, or null if this operation is not defined
-
__rlshift__
Equivalent to the standard Python __rlshift__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the lshift, or null if this operation is not defined.
-
__ilshift__
Equivalent to the standard Python __ilshift__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the ilshift, or null if this operation is not defined
-
_lshift
Implements the Python expressionthis << o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the lshift.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_ilshift
Implements the Python expressionthis <<= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the ilshift.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__rshift__
Equivalent to the standard Python __rshift__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the rshift, or null if this operation is not defined
-
__rrshift__
Equivalent to the standard Python __rrshift__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the rshift, or null if this operation is not defined.
-
__irshift__
Equivalent to the standard Python __irshift__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the irshift, or null if this operation is not defined
-
_rshift
Implements the Python expressionthis >> o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the rshift.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_irshift
Implements the Python expressionthis >>= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the irshift.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__and__
Equivalent to the standard Python __and__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the and, or null if this operation is not defined
-
__rand__
Equivalent to the standard Python __rand__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the and, or null if this operation is not defined.
-
__iand__
Equivalent to the standard Python __iand__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the iand, or null if this operation is not defined
-
_and
Implements the Python expressionthis & o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the and.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_iand
Implements the Python expressionthis &= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the iand.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__or__
Equivalent to the standard Python __or__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the or, or null if this operation is not defined
-
__ror__
Equivalent to the standard Python __ror__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the or, or null if this operation is not defined.
-
__ior__
Equivalent to the standard Python __ior__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the ior, or null if this operation is not defined
-
_or
Implements the Python expressionthis | o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the or.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_ior
Implements the Python expressionthis |= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the ior.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
__xor__
Equivalent to the standard Python __xor__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the xor, or null if this operation is not defined
-
__rxor__
Equivalent to the standard Python __rxor__ method- Parameters:
other
- the object to perform this binary operation with (the left-hand operand).- Returns:
- the result of the xor, or null if this operation is not defined.
-
__ixor__
Equivalent to the standard Python __ixor__ method- Parameters:
other
- the object to perform this binary operation with (the right-hand operand).- Returns:
- the result of the ixor, or null if this operation is not defined
-
_xor
Implements the Python expressionthis ^ o2
- Parameters:
o2
- the object to perform this binary operation with.- Returns:
- the result of the xor.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_ixor
Implements the Python expressionthis ^= o2
- Parameters:
o2
- the object to perform this inplace binary operation with.- Returns:
- the result of the ixor.
- Throws:
PyException
-TypeError
if this operation can't be performed with these operands.
-
_jcallexc
A convenience function for PyProxys.- Throws:
Throwable
-
_jthrow
-
_jcall
-
invoke
Shortcut for calling a method on a PyObject from Java. This form is equivalent to o.__getattr__(name).__call__(args, keywords)- Parameters:
name
- the name of the method to call. This must be an interned string!args
- an array of the arguments to the call.keywords
- the keywords to use in the call.- Returns:
- the result of calling the method name with args and keywords.
-
invoke
-
invoke
Shortcut for calling a method on a PyObject with no args.- Parameters:
name
- the name of the method to call. This must be an interned string!- Returns:
- the result of calling the method name with no args
-
invoke
Shortcut for calling a method on a PyObject with one arg.- Parameters:
name
- the name of the method to call. This must be an interned string!arg1
- the one argument of the method.- Returns:
- the result of calling the method name with arg1
-
invoke
Shortcut for calling a method on a PyObject with two args.- Parameters:
name
- the name of the method to call. This must be an interned string!arg1
- the first argument of the method.arg2
- the second argument of the method.- Returns:
- the result of calling the method name with arg1 and arg2
-
invoke
Shortcut for calling a method on a PyObject with one extra initial argument.- Parameters:
name
- the name of the method to call. This must be an interned string!arg1
- the first argument of the method.args
- an array of the arguments to the call.keywords
- the keywords to use in the call.- Returns:
- the result of calling the method name with arg1 args and keywords
-
fastGetDict
xxx implements where meaningful- Returns:
- internal object per instance dict or null
-
getDict
xxx implements where meaningful- Returns:
- internal object __dict__ or null
-
setDict
-
delDict
public void delDict() -
implementsDescrGet
public boolean implementsDescrGet() -
implementsDescrSet
public boolean implementsDescrSet() -
implementsDescrDelete
public boolean implementsDescrDelete() -
isDataDescr
public boolean isDataDescr() -
__get__
Get descriptor for this PyObject.- Parameters:
obj
- - the instance accessing this descriptor. Can be null if this is being accessed by a type.type
- - the type accessing this descriptor. Will be null if obj exists as obj is of the type accessing the descriptor.- Returns:
- - the object defined for this descriptor for the given obj and type.
-
__set__
-
__delete__
-
asName
-
__reduce__
Used for pickling. Default implementation calls object___reduce__.- Returns:
- a tuple of (class, tuple)
-
__reduce_ex__
Used for pickling. If the subclass specifies __reduce__, it will override __reduce_ex__ in the base-class, even if __reduce_ex__ was called with an argument.- Parameters:
arg
- PyInteger specifying reduce algorithm (method without this argument defaults to 0).- Returns:
- a tuple of (class, tuple)
-
__reduce_ex__
-
__getnewargs__
-
object___subclasshook__
-
asString
- Throws:
PyObject.ConversionException
-
asString
-
asStringOrNull
- Throws:
PyObject.ConversionException
-
asStringOrNull
-
asName
- Throws:
PyObject.ConversionException
-
asInt
- Throws:
PyObject.ConversionException
-
asInt
public int asInt()Convert this object into an int. Throws a PyException on failure.- Returns:
- an int value
-
asLong
- Throws:
PyObject.ConversionException
-
asLong
public long asLong()Convert this object into a long. Throws a PyException on failure.- Returns:
- an long value
-
asDouble
public double asDouble()Convert this object into a double. Throws a PyException on failure.- Returns:
- a double value
-
asIndex
public int asIndex()Convert this object into an index-sized integer. Throws a PyException on failure.- Returns:
- an index-sized int
-
asIndex
Convert this object into an index-sized integer. Throws a Python exception on Overflow if specified an exception type for err.- Parameters:
err
- the Python exception to raise on OverflowErrors- Returns:
- an index-sized int
-