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 um objeto em Python e suporta pesquisa membro dinâmico. Qualquer acesso de membros como object.foo dinamicamente irá solicitar o tempo de execução Python para um membro com o nome especificado neste objeto.

PythonObject é passado para e voltado dentre todas as chamadas de função Python e referências membros. Suporta operadores aritméticos e de comparação padrão do Python.

Internamente, PythonObject é implementado como um ponteiro contou-referência para uma API Python C PyObject .

  • Uma descrição textual deste PythonObject , produzido por Python.str .

    Declaração

    public var description: String { get }
  • Declaração

    public var playgroundDescription: Any { get }
  • Declaração

    public var customMirror: Mirror { get }
  • Cria uma nova instância de um PythonConvertible valor.

    Declaração

    init<T>(_ object: T) where T : PythonConvertible
  • Declaração

    public init(_ object: PythonObject)
  • Declaração

    public var pythonObject: PythonObject { get }
  • Retorna uma versão que pode ser chamado desta PythonObject . Quando chamado, o resultado lança um erro Swift se a função Python subjacente lança uma exceção Python.

    Declaração

    var throwing: ThrowingPythonObject { get }
  • Retorna um PythonObject invólucro capaz de acessos membros.

    Declaração

    var checking: CheckingPythonObject { get }
  • Declaração

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • O acesso ao elemento correspondente ao especificado PythonConvertible valores representando uma chave.

    Observação

    Isto é equivalente a object[key] em Python.

    Declaração

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • Converte em 2 tuplas.

    Declaração

    var tuple2: (PythonObject, PythonObject) { get }
  • Converte em uma tupla de 3.

    Declaração

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • Converte em uma tupla de 4.

    Declaração

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • Chamada self com os argumentos posicionais especificados.

    Condição prévia

    self deve ser um que pode ser chamado Python.

    Declaração

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

    Parâmetros

    args

    Argumentos posicionais para o Python chamável.

  • Chamada self com os argumentos especificados.

    Condição prévia

    self deve ser um que pode ser chamado Python.

    Declaração

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

    Parâmetros

    args

    Argumentos posicionais ou de palavra-chave para o Python chamável.

  • Declaração

    init(tupleOf elements: PythonConvertible...)
  • Declaração

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element == PythonConvertible
  • Declaração

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element : PythonConvertible
  • Declaração

    static func + (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func - (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func * (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func / (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func += (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func -= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func *= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func /= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func & (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func | (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func ^ (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func &= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func |= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    static func ^= (lhs: inout PythonObject, rhs: PythonObject)
  • Declaração

    prefix static func ~ (operand: `Self`) -> PythonObject
  • Declaração

    public init<T>(exactly value: T) where T : BinaryInteger
  • Declaração

    public typealias Magnitude = PythonObject
  • Declaração

    public var magnitude: PythonObject { get }
  • Declaração

    public prefix static func - (operand: `Self`) -> PythonObject
  • Declaração

    public typealias Stride = PythonObject
  • Declaração

    public func distance(to other: PythonObject) -> Stride
  • Declaração

    public func advanced(by stride: Stride) -> PythonObject
  • Declaração

    public static func == (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    public static func != (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    public static func < (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    public static func <= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    public static func > (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    public static func >= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Declaração

    static func == (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func != (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func < (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func <= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func > (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    static func >= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Declaração

    public func hash(into hasher: inout Hasher)
  • Declaração

    public typealias Index = PythonObject
  • Declaração

    public typealias Element = PythonObject
  • Declaração

    public var startIndex: Index { get }
  • Declaração

    public var endIndex: Index { get }
  • Declaração

    public func index(after i: Index) -> Index
  • Declaração

    public subscript(index: PythonObject) -> PythonObject { get set }
  • Declaração

    public struct Iterator : IteratorProtocol
  • Declaração

    public func makeIterator() -> Iterator
  • Declaração

    public init(booleanLiteral value: Bool)
  • Declaração

    public init(integerLiteral value: Int)
  • Declaração

    public init(floatLiteral value: Double)
  • Declaração

    public init(stringLiteral value: String)
  • Declaração

    public init(arrayLiteral elements: PythonObject...)
  • Declaração

    public typealias Key = PythonObject
  • Declaração

    public typealias Value = PythonObject
  • Declaração

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