PythonObjet

@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 représente un objet en Python et prend en charge la recherche dynamique de membres. Tout accès membre comme object.foo demandera dynamiquement le runtime Python pour un membre portant le nom spécifié dans cet objet.

PythonObject est transmis et renvoyé par tous les appels de fonction Python et références de membres. Il prend en charge les opérateurs arithmétiques et de comparaison Python standard.

En interne, PythonObject est implémenté en tant que pointeur à références vers une API Python C PyObject .

  • Une description textuelle de ce PythonObject , produite par Python.str .

    Déclaration

    public var description: String { get }
  • Déclaration

    public var playgroundDescription: Any { get }
  • Déclaration

    public var customMirror: Mirror { get }
  • Crée une nouvelle instance à partir d'une valeur PythonConvertible .

    Déclaration

    init<T>(_ object: T) where T : PythonConvertible
  • Déclaration

    public init(_ object: PythonObject)
  • Déclaration

    public var pythonObject: PythonObject { get }
  • Renvoie une version appelable de ce PythonObject . Lorsqu'il est appelé, le résultat renvoie une erreur Swift si la fonction Python sous-jacente renvoie une exception Python.

    Déclaration

    var throwing: ThrowingPythonObject { get }
  • Renvoie un wrapper PythonObject capable d'accéder aux membres.

    Déclaration

    var checking: CheckingPythonObject { get }
  • Déclaration

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • Accédez à l'élément correspondant aux valeurs PythonConvertible spécifiées représentant une clé.

    Note

    C'est l'équivalent de object[key] en Python.

    Déclaration

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • Se convertit en 2-tuples.

    Déclaration

    var tuple2: (PythonObject, PythonObject) { get }
  • Se convertit en 3-tuples.

    Déclaration

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • Se convertit en 4-tuples.

    Déclaration

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • Appelez self avec les arguments de position spécifiés.

    Condition préalable

    self doit être un appelable en Python.

    Déclaration

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

    Paramètres

    args

    Arguments positionnels pour l'appelable Python.

  • Appelez self avec les arguments spécifiés.

    Condition préalable

    self doit être un appelable en Python.

    Déclaration

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

    Paramètres

    args

    Arguments de position ou de mot-clé pour l'appelable Python.

  • Déclaration

    init(tupleOf elements: PythonConvertible...)
  • Déclaration

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

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element : PythonConvertible
  • Déclaration

    static func + (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func - (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func * (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func / (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func += (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func -= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func *= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func /= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func & (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func | (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func ^ (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func &= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func |= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    static func ^= (lhs: inout PythonObject, rhs: PythonObject)
  • Déclaration

    prefix static func ~ (operand: `Self`) -> PythonObject
  • Déclaration

    public init<T>(exactly value: T) where T : BinaryInteger
  • Déclaration

    public typealias Magnitude = PythonObject
  • Déclaration

    public var magnitude: PythonObject { get }
  • Déclaration

    public prefix static func - (operand: `Self`) -> PythonObject
  • Déclaration

    public typealias Stride = PythonObject
  • Déclaration

    public func distance(to other: PythonObject) -> Stride
  • Déclaration

    public func advanced(by stride: Stride) -> PythonObject
  • Déclaration

    public static func == (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Déclaration

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

    public static func < (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Déclaration

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

    public static func > (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Déclaration

    public static func >= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • Déclaration

    static func == (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func != (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func < (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func <= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func > (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    static func >= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • Déclaration

    public func hash(into hasher: inout Hasher)
  • Déclaration

    public typealias Index = PythonObject
  • Déclaration

    public typealias Element = PythonObject
  • Déclaration

    public var startIndex: Index { get }
  • Déclaration

    public var endIndex: Index { get }
  • Déclaration

    public func index(after i: Index) -> Index
  • Déclaration

    public subscript(index: PythonObject) -> PythonObject { get set }
  • Déclaration

    public struct Iterator : IteratorProtocol
  • Déclaration

    public func makeIterator() -> Iterator
  • Déclaration

    public init(booleanLiteral value: Bool)
  • Déclaration

    public init(integerLiteral value: Int)
  • Déclaration

    public init(floatLiteral value: Double)
  • Déclaration

    public init(stringLiteral value: String)
  • Déclaration

    public init(arrayLiteral elements: PythonObject...)
  • Déclaration

    public typealias Key = PythonObject
  • Déclaration

    public typealias Value = PythonObject
  • Déclaration

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