public struct ThrowingPythonObject
A PythonObject
wrapper that enables throwing method calls.
Exceptions produced by Python functions are reflected as Swift errors and
thrown.
Note
It is intentional thatThrowingPythonObject
does not have the
@dynamicCallable
attribute because the call syntax is unintuitive:
x.throwing(arg1, arg2, ...)
. The methods will still be named
dynamicallyCall
until further discussion/design.
-
Call
self
with the specified positional arguments. If the call fails for some reason,PythonError.invalidCall
is thrown.Precondition
self
must be a Python callable.Declaration
@discardableResult public func dynamicallyCall( withArguments args: PythonConvertible...) throws -> PythonObject
Parameters
args
Positional arguments for the Python callable.
-
Call
self
with the specified positional arguments. If the call fails for some reason,PythonError.invalidCall
is thrown.Precondition
self
must be a Python callable.Declaration
@discardableResult public func dynamicallyCall( withArguments args: [PythonConvertible] = []) throws -> PythonObject
Parameters
args
Positional arguments for the Python callable.
-
Call
self
with the specified arguments. If the call fails for some reason,PythonError.invalidCall
is thrown.Precondition
self
must be a Python callable.Declaration
@discardableResult public func dynamicallyCall( withKeywordArguments args: KeyValuePairs<String, PythonConvertible> = [:]) throws -> PythonObject
Parameters
args
Positional or keyword arguments for the Python callable.
-
Converts to a 2-tuple, if possible.
Declaration
public var tuple2: (PythonObject, PythonObject)? { get }
-
Converts to a 3-tuple, if possible.
Declaration
public var tuple3: (PythonObject, PythonObject, PythonObject)? { get }
-
Converts to a 4-tuple, if possible.
Declaration
public var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject)? { get }