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 rappresenta un oggetto in Python e supporta la ricerca dinamica dei membri. Qualsiasi accesso membro come object.foo richiederà dinamicamente il runtime Python per un membro con il nome specificato in questo oggetto.

PythonObject viene passato e restituito da tutte le chiamate di funzioni Python e i riferimenti ai membri. Supporta gli operatori aritmetici e di confronto Python standard.

Internamente, PythonObject è implementato come puntatore con conteggio dei riferimenti a un'API Python C PyObject .

  • Una descrizione testuale di questo PythonObject , prodotta da Python.str .

    Dichiarazione

    public var description: String { get }
  • Dichiarazione

    public var playgroundDescription: Any { get }
  • Dichiarazione

    public var customMirror: Mirror { get }
  • Crea una nuova istanza da un valore PythonConvertible .

    Dichiarazione

    init<T>(_ object: T) where T : PythonConvertible
  • Dichiarazione

    public init(_ object: PythonObject)
  • Dichiarazione

    public var pythonObject: PythonObject { get }
  • Restituisce una versione richiamabile di questo PythonObject . Quando viene chiamato, il risultato genera un errore Swift se la funzione Python sottostante genera un'eccezione Python.

    Dichiarazione

    var throwing: ThrowingPythonObject { get }
  • Restituisce un wrapper PythonObject in grado di accedere ai membri.

    Dichiarazione

    var checking: CheckingPythonObject { get }
  • Dichiarazione

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • Accedi all'elemento corrispondente ai valori PythonConvertible specificati che rappresentano una chiave.

    Nota

    Questo è equivalente a object[key] in Python.

    Dichiarazione

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • Converte in una tupla di 2.

    Dichiarazione

    var tuple2: (PythonObject, PythonObject) { get }
  • Converte in una tupla di 3 elementi.

    Dichiarazione

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • Converte in una tupla di 4 elementi.

    Dichiarazione

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • Chiama self con gli argomenti posizionali specificati.

    Precondizione

    self deve essere un richiamabile Python.

    Dichiarazione

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

    Parametri

    args

    Argomenti posizionali per il richiamabile Python.

  • Chiama self con gli argomenti specificati.

    Precondizione

    self deve essere un richiamabile Python.

    Dichiarazione

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

    Parametri

    args

    Argomenti posizionali o di parole chiave per il richiamabile Python.

  • Dichiarazione

    init(tupleOf elements: PythonConvertible...)
  • Dichiarazione

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

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element : PythonConvertible
  • Dichiarazione

    static func + (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func - (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func * (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func / (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func += (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func -= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func *= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func /= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func & (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func | (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func ^ (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func &= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func |= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    static func ^= (lhs: inout PythonObject, rhs: PythonObject)
  • Dichiarazione

    prefix static func ~ (operand: `Self`) -> PythonObject
  • Dichiarazione

    public init<T>(exactly value: T) where T : BinaryInteger
  • Dichiarazione

    public typealias Magnitude = PythonObject
  • Dichiarazione

    public var magnitude: PythonObject { get }
  • Dichiarazione

    public prefix static func - (operand: `Self`) -> PythonObject
  • Dichiarazione

    public typealias Stride = PythonObject
  • Dichiarazione

    public func distance(to other: PythonObject) -> Stride
  • Dichiarazione

    public func advanced(by stride: Stride) -> PythonObject
  • Dichiarazione

    public static func == (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Dichiarazione

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

    public static func < (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Dichiarazione

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

    public static func > (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Dichiarazione

    public static func >= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Dichiarazione

    static func == (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func != (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func < (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func <= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func > (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    static func >= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Dichiarazione

    public func hash(into hasher: inout Hasher)
  • Dichiarazione

    public typealias Index = PythonObject
  • Dichiarazione

    public typealias Element = PythonObject
  • Dichiarazione

    public var startIndex: Index { get }
  • Dichiarazione

    public var endIndex: Index { get }
  • Dichiarazione

    public func index(after i: Index) -> Index
  • Dichiarazione

    public subscript(index: PythonObject) -> PythonObject { get set }
  • Dichiarazione

    public struct Iterator : IteratorProtocol
  • Dichiarazione

    public func makeIterator() -> Iterator
  • Dichiarazione

    public init(booleanLiteral value: Bool)
  • Dichiarazione

    public init(integerLiteral value: Int)
  • Dichiarazione

    public init(floatLiteral value: Double)
  • Dichiarazione

    public init(stringLiteral value: String)
  • Dichiarazione

    public init(arrayLiteral elements: PythonObject...)
  • Dichiarazione

    public typealias Key = PythonObject
  • Dichiarazione

    public typealias Value = PythonObject
  • Dichiarazione

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