PythonObject

@dynamicCallable
@dynamicMemberLookup
public struct PythonObject
extension PythonObject : CustomStringConvertible
extension PythonObject : CustomPlaygroundDisplayConvertible
extension PythonObject : CustomReflectable
extension PythonObject : PythonConvertible, ConvertibleFromPython
extension PythonObject : SignedNumeric
extension PythonObject : Strideable
extension PythonObject : Equatable, Comparable
extension PythonObject : Hashable
extension PythonObject : MutableCollection
extension PythonObject : Sequence
extension PythonObject : ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral,
ExpressibleByFloatLiteral, ExpressibleByStringLiteral
extension PythonObject : ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral

PythonObject representa un objeto en Python y soporta las operaciones de búsqueda miembro dinámico. Cualquier miembro de acceso como object.foo dinámicamente solicitará la ejecución de Python para un miembro con el nombre especificado en este objeto.

PythonObject se pasa hacia y regresó de todas las llamadas de función de Python y referencias miembros. Admite operadores aritméticos y de comparación estándar de Python.

Internamente, PythonObject se implementa como un puntero de referencia contado a un Python C API PyObject .

  • Una descripción textual de este PythonObject , producido por Python.str .

    Declaración

    public var description: String { get }
  • Declaración

    public var playgroundDescription: Any { get }
  • Declaración

    public var customMirror: Mirror { get }
  • Crea una nueva instancia de un PythonConvertible valor.

    Declaración

    init<T>(_ object: T) where T : PythonConvertible
  • Declaración

    public init(_ object: PythonObject)
  • Declaración

    public var pythonObject: PythonObject { get }
  • Devuelve una versión de este exigible PythonObject . Cuando se llama, el resultado arroja un error de Swift si la función subyacente de Python arroja una excepción de Python.

    Declaración

    var throwing: ThrowingPythonObject { get }
  • Devuelve un PythonObject envoltorio capaz de accesos miembros.

    Declaración

    var checking: CheckingPythonObject { get }
  • Declaración

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • Acceso el elemento correspondiente a la especificada PythonConvertible valores que representan una clave.

    Nota

    Esto es equivalente a object[key] en Python.

    Declaración

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • Se convierte en una tupla de 2.

    Declaración

    var tuple2: (PythonObject, PythonObject) { get }
  • Se convierte en una tupla de 3.

    Declaración

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • Se convierte en una tupla de 4.

    Declaración

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • Llame a self con los argumentos posicionales especificadas.

    Condición previa

    self debe haber un exigible Python.

    Declaración

    @discardableResult
    func dynamicallyCall(
        withArguments args: [PythonConvertible] = []) -> PythonObject

    Parámetros

    args

    Argumentos posicionales para Python invocable.

  • Llame a self con los argumentos especificados.

    Condición previa

    self debe haber un exigible Python.

    Declaración

    @discardableResult
    func dynamicallyCall(
        withKeywordArguments args:
        KeyValuePairs<String, PythonConvertible> = [:]) -> PythonObject

    Parámetros

    args

    Argumentos posicionales o de palabras clave para el Python invocable.

  • Declaración

    init(tupleOf elements: PythonConvertible...)
  • Declaración

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element == PythonConvertible
  • Declaración

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element : PythonConvertible
  • Declaración

    static func + (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func - (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func * (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func / (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func += (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func -= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func *= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func /= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func & (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func | (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func ^ (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func &= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func |= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    static func ^= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaración

    prefix static func ~ (operand: `Self`) -> PythonObject
  • Declaración

    public init<T>(exactly value: T) where T : BinaryInteger
  • Declaración

    public typealias Magnitude = PythonObject
  • Declaración

    public var magnitude: PythonObject { get }
  • Declaración

    public prefix static func - (operand: `Self`) -> PythonObject
  • Declaración

    public typealias Stride = PythonObject
  • Declaración

    public func distance(to other: PythonObject) -> Stride
  • Declaración

    public func advanced(by stride: Stride) -> PythonObject
  • Declaración

    public static func == (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    public static func != (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    public static func < (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    public static func <= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    public static func > (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    public static func >= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaración

    static func == (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func != (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func < (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func <= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func > (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    static func >= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaración

    public func hash(into hasher: inout Hasher)
  • Declaración

    public typealias Index = PythonObject
  • Declaración

    public typealias Element = PythonObject
  • Declaración

    public var startIndex: Index { get }
  • Declaración

    public var endIndex: Index { get }
  • Declaración

    public func index(after i: Index) -> Index
  • Declaración

    public subscript(index: PythonObject) -> PythonObject { get set }
  • Declaración

    public struct Iterator : IteratorProtocol
  • Declaración

    public func makeIterator() -> Iterator
  • Declaración

    public init(booleanLiteral value: Bool)
  • Declaración

    public init(integerLiteral value: Int)
  • Declaración

    public init(floatLiteral value: Double)
  • Declaración

    public init(stringLiteral value: String)
  • Declaración

    public init(arrayLiteral elements: PythonObject...)
  • Declaración

    public typealias Key = PythonObject
  • Declaración

    public typealias Value = PythonObject
  • Declaración

    public init(dictionaryLiteral elements: (PythonObject, PythonObject)...)