Package ai.timefold.jpyinterpreter
Interface PythonLikeObject
- All Known Subinterfaces:
PythonBytesLikeObject,PythonIterator<T>,PythonLikeFunction,PythonNumber
- All Known Implementing Classes:
AbstractPythonLikeObject,ArithmeticError,AttributeError,BinaryDunderBuiltin,BlockingIOError,BoundPythonLikeFunction,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,CPythonBackedPythonLikeObject,CPythonException,CPythonType,DelegatePythonIterator,DeprecationWarning,DictItemView,DictKeyView,DictValueView,Ellipsis,EncodingWarning,EOFError,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratedFunctionMethodReference,GeneratorExit,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,JavaMethodReference,JavaObjectWrapper,KeyboardInterrupt,KeyError,LookupError,MemoryError,ModuleNotFoundError,MultiDispatchJavaMethodReference,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,PythonAssertionError,PythonBaseException,PythonBoolean,PythonByteArray,PythonBytes,PythonCell,PythonCode,PythonComplex,PythonDate,PythonDateTime,PythonDecimal,PythonException,PythonFloat,PythonGenerator,PythonInteger,PythonKnownFunctionType,PythonLikeDict,PythonLikeFrozenSet,PythonLikeFunctionWrapper,PythonLikeGenericType,PythonLikeList,PythonLikeSet,PythonLikeTuple,PythonLikeType,PythonModule,PythonNone,PythonObjectWrapper,PythonRange,PythonSlice,PythonString,PythonSuperObject,PythonTime,PythonTimeDelta,PythonTraceback,PythonTzinfo,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TernaryDunderBuiltin,TimeoutError,TypeError,UnaryDunderBuiltin,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError
public interface PythonLikeObject
Represents an Object that can be interacted with like a Python Object.
A PythonLikeObject can refer to a Java Object, a CPython Object, or
be an Object constructed by the Java Python Interpreter.
-
Method Summary
Modifier and TypeMethodDescriptionvoid$deleteAttribute(String attributeName) Delete an attribute by name.default PythonLikeObject$getAttributeOrError(String attributeName) Gets an attribute by name.$getAttributeOrNull(String attributeName) Gets an attribute by name.default PythonLikeTypeReturn a generic version of$getType().$getType()Returns the type describing the objectdefault PythonLikeObject$method$__delattr__(PythonString pythonName) default PythonLikeObject$method$__eq__(PythonLikeObject other) default PythonLikeObjectdefault PythonLikeObject$method$__format__(PythonLikeObject formatString) default PythonLikeObject$method$__getattribute__(PythonString pythonName) default PythonLikeObjectdefault PythonLikeObject$method$__ne__(PythonLikeObject other) default PythonLikeObjectdefault PythonLikeObject$method$__setattr__(PythonString pythonName, PythonLikeObject value) default PythonStringvoid$setAttribute(String attributeName, PythonLikeObject value) Sets an attribute by name.
-
Method Details
-
$getAttributeOrNull
Gets an attribute by name.- Parameters:
attributeName- Name of the attribute to get- Returns:
- The attribute of the object that corresponds with attributeName
- Throws:
AttributeError- if the attribute does not exist
-
$getAttributeOrError
Gets an attribute by name.- Parameters:
attributeName- Name of the attribute to get- Returns:
- The attribute of the object that corresponds with attributeName
- Throws:
AttributeError- if the attribute does not exist
-
$setAttribute
Sets an attribute by name.- Parameters:
attributeName- Name of the attribute to setvalue- Value to set the attribute to
-
$deleteAttribute
Delete an attribute by name.- Parameters:
attributeName- Name of the attribute to delete
-
$getType
PythonLikeType $getType()Returns the type describing the object- Returns:
- the type describing the object
-
$getGenericType
Return a generic version of$getType(). This is used in bytecode generation and not at runtime. For example, for a list of integers, this return list[int], while getType returns list. Both methods are needed so type([1,2,3]) is type(['a', 'b', 'c']) return True.- Returns:
- the generic version of this object's type. Must not be used in identity checks.
-
$method$__getattribute__
-
$method$__setattr__
-
$method$__delattr__
-
$method$__eq__
-
$method$__ne__
-
$method$__str__
-
$method$__repr__
-
$method$__format__
-
$method$__format__
-
$method$__hash__
-