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 : MutableCollection
extension PythonObject : Hashable
extension PythonObject : Sequence
extension PythonObject : ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral,
ExpressibleByFloatLiteral, ExpressibleByStringLiteral
extension PythonObject : ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral

PythonObject یک شی را در پایتون نشان می دهد و از جستجوی اعضای پویا پشتیبانی می کند. هر دسترسی عضوی مانند object.foo به صورت پویا زمان اجرای پایتون را برای عضوی با نام مشخص شده در این شی درخواست می کند.

PythonObject به همه فراخوانی‌های تابع پایتون و ارجاعات اعضا ارسال می‌شود و از آن بازگردانده می‌شود. از عملگرهای استاندارد ریاضی پایتون و مقایسه پشتیبانی می کند.

در داخل، PythonObject به عنوان یک اشاره گر شمارش مرجع به PyObject Python C API پیاده سازی می شود.

  • شرح متنی این PythonObject , تولید شده توسط Python.str .

    اعلام

    public var description: String { get }
  • اعلام

    public var playgroundDescription: Any { get }
  • اعلام

    public var customMirror: Mirror { get }
  • یک نمونه جدید از یک مقدار PythonConvertible ایجاد می کند.

    اعلام

    init<T>(_ object: T) where T : PythonConvertible
  • اعلام

    public init(_ object: PythonObject)
  • اعلام

    public var pythonObject: PythonObject { get }
  • نسخه قابل فراخوانی این PythonObject را برمی گرداند. هنگامی که فراخوانی می شود، اگر تابع پایتون زیربنای یک استثنا پایتون را ایجاد کند، نتیجه یک خطای سوئیفت ایجاد می کند.

    اعلام

    var throwing: ThrowingPythonObject { get }
  • یک بسته بندی PythonObject با قابلیت دسترسی اعضا را برمی گرداند.

    اعلام

    var checking: CheckingPythonObject { get }
  • اعلام

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • به عنصر مربوط به مقادیر مشخص شده PythonConvertible که یک کلید را نشان می دهد دسترسی پیدا کنید.

    توجه داشته باشید

    این معادل object[key] در پایتون است.

    اعلام

    subscript(key: PythonConvertible...) -> PythonObject { get nonmutating set }
  • به 2 تایی تبدیل می شود.

    اعلام

    var tuple2: (PythonObject, PythonObject) { get }
  • به 3 تایی تبدیل می شود.

    اعلام

    var tuple3: (PythonObject, PythonObject, PythonObject) { get }
  • به 4 تایی تبدیل می شود.

    اعلام

    var tuple4: (PythonObject, PythonObject, PythonObject, PythonObject) { get }
  • با آرگومان های موقعیتی مشخص شده self فراخوانی کنید.

    پیش شرط

    self باید قابل فراخوانی پایتون باشد.

    اعلام

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

    مولفه های

    args

    آرگومان های موقعیتی برای Python callable.

  • با آرگومان های مشخص شده self فراخوانی کنید.

    پیش شرط

    self باید قابل فراخوانی پایتون باشد.

    اعلام

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

    مولفه های

    args

    آرگومان های موقعیت یا کلیدواژه برای Python callable.

  • اعلام

    init(tupleOf elements: PythonConvertible...)
  • اعلام

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element == PythonConvertible
  • اعلام

    init<T : Collection>(tupleContentsOf elements: T)
        where T.Element : PythonConvertible
  • اعلام

    static func + (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func - (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func * (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func / (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func += (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func -= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func *= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func /= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func & (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func | (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func ^ (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func &= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func |= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    static func ^= (lhs: inout PythonObject, rhs: PythonObject)
  • اعلام

    prefix static func ~ (operand: `Self`) -> PythonObject
  • اعلام

    public init<T>(exactly value: T) where T : BinaryInteger
  • اعلام

    public typealias Magnitude = PythonObject
  • اعلام

    public var magnitude: PythonObject { get }
  • اعلام

    public prefix static func - (operand: `Self`) -> PythonObject
  • اعلام

    public typealias Stride = PythonObject
  • اعلام

    public func distance(to other: PythonObject) -> Stride
  • اعلام

    public func advanced(by stride: Stride) -> PythonObject
  • اعلام

    public static func == (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    public static func != (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    public static func < (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    public static func <= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    public static func > (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    public static func >= (lhs: PythonObject, rhs: PythonObject) -> Bool
  • اعلام

    static func == (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func != (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func < (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func <= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func > (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    static func >= (lhs: PythonObject, rhs: PythonObject) -> PythonObject
  • اعلام

    public func hash(into hasher: inout Hasher)
  • اعلام

    public typealias Index = PythonObject
  • اعلام

    public typealias Element = PythonObject
  • اعلام

    public var startIndex: Index { get }
  • اعلام

    public var endIndex: Index { get }
  • اعلام

    public func index(after i: Index) -> Index
  • اعلام

    public subscript(index: PythonObject) -> PythonObject { get set }
  • اعلام

    public struct Iterator : IteratorProtocol
  • اعلام

    public func makeIterator() -> Iterator
  • اعلام

    public init(booleanLiteral value: Bool)
  • اعلام

    public init(integerLiteral value: Int)
  • اعلام

    public init(floatLiteral value: Double)
  • اعلام

    public init(stringLiteral value: String)
  • اعلام

    public init(arrayLiteral elements: PythonObject...)
  • اعلام

    public typealias Key = PythonObject
  • اعلام

    public typealias Value = PythonObject
  • اعلام

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