Obiekt Pythona

@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 reprezentuje obiekt w Pythonie i obsługuje dynamiczne wyszukiwanie elementów członkowskich. Każdy dostęp członkowski, taki jak object.foo , będzie dynamicznie żądał środowiska wykonawczego Pythona dla członka o określonej nazwie w tym obiekcie.

PythonObject jest przekazywany i zwracany przez wszystkie wywołania funkcji Pythona i odniesienia do elementów członkowskich. Obsługuje standardowe operatory arytmetyczne i porównania w języku Python.

Wewnętrznie PythonObject jest zaimplementowany jako wskaźnik zliczany przez referencje do API Pythona C PyObject .

  • Tekstowy opis tego PythonObject , stworzony przez Python.str .

    Deklaracja

    public var description: String { get }
  • Deklaracja

    public var playgroundDescription: Any { get }
  • Deklaracja

    public var customMirror: Mirror { get }
  • Tworzy nową instancję na podstawie wartości PythonConvertible .

    Deklaracja

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

    public init(_ object: PythonObject)
  • Deklaracja

    public var pythonObject: PythonObject { get }
  • Zwraca wywoływalną wersję tego PythonObject . Po wywołaniu wynik zgłasza błąd Swift, jeśli podstawowa funkcja Pythona zgłasza wyjątek Pythona.

    Deklaracja

    var throwing: ThrowingPythonObject { get }
  • Zwraca opakowanie PythonObject umożliwiające dostęp do elementów członkowskich.

    Deklaracja

    var checking: CheckingPythonObject { get }
  • Deklaracja

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • Uzyskaj dostęp do elementu odpowiadającego określonym wartościom PythonConvertible reprezentującym klucz.

    Notatka

    Jest to odpowiednik object[key] w Pythonie.

    Deklaracja

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • Konwertuje na 2-krotkę.

    Deklaracja

    var tuple2: (PythonObject, PythonObject) { get }
  • Konwertuje na 3-krotkę.

    Deklaracja

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • Konwertuje na krotkę 4-krotną.

    Deklaracja

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • Wywołaj self z określonymi argumentami pozycyjnymi.

    Warunek wstępny

    self musi być wywoływalne w Pythonie.

    Deklaracja

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

    Parametry

    args

    Argumenty pozycyjne dla wywołania języka Python.

  • Wywołaj self z określonymi argumentami.

    Warunek wstępny

    self musi być wywoływalne w Pythonie.

    Deklaracja

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

    Parametry

    args

    Argumenty pozycyjne lub słowa kluczowe dla wywoływalnego języka Python.

  • Deklaracja

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public typealias Magnitude = PythonObject
  • Deklaracja

    public var magnitude: PythonObject { get }
  • Deklaracja

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

    public typealias Stride = PythonObject
  • Deklaracja

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public typealias Index = PythonObject
  • Deklaracja

    public typealias Element = PythonObject
  • Deklaracja

    public var startIndex: Index { get }
  • Deklaracja

    public var endIndex: Index { get }
  • Deklaracja

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

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

    public struct Iterator : IteratorProtocol
  • Deklaracja

    public func makeIterator() -> Iterator
  • Deklaracja

    public init(booleanLiteral value: Bool)
  • Deklaracja

    public init(integerLiteral value: Int)
  • Deklaracja

    public init(floatLiteral value: Double)
  • Deklaracja

    public init(stringLiteral value: String)
  • Deklaracja

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

    public typealias Key = PythonObject
  • Deklaracja

    public typealias Value = PythonObject
  • Deklaracja

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