Pythonオブジェクト

@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 Python のオブジェクトを表し、動的メンバー検索をサポートします。 object.fooなどのメンバー アクセスは、このオブジェクト内の指定された名前を持つメンバーの Python ランタイムを動的に要求します。

PythonObject 、すべての Python 関数呼び出しとメンバー参照に渡され、そこから返されます。標準の Python 算術演算子と比較演算子をサポートします。

内部的には、 PythonObject 、Python C API PyObjectへの参照カウントされたポインターとして実装されます。

  • Python.strによって生成される、このPythonObjectのテキストによる説明。

    宣言

    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の呼び出し可能なバージョンを返します。呼び出されたときに、基になる Python 関数が Python 例外をスローした場合、結果は Swift エラーをスローします。

    宣言

    var throwing: ThrowingPythonObject { get }
  • メンバーアクセスが可能なPythonObjectラッパーを返します。

    宣言

    var checking: CheckingPythonObject { get }
  • 宣言

    subscript(dynamicMember memberName: String) -> PythonObject { get nonmutating set }
  • キーを表す指定されたPythonConvertible値に対応する要素にアクセスします。

    注記

    これは、Python の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 Python 呼び出し可能である必要があります。

    宣言

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

    パラメーター

    args

    Python 呼び出し可能オブジェクトの位置引数。

  • 引数を指定してselfを呼び出します。

    前提条件

    self Python 呼び出し可能である必要があります。

    宣言

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

    パラメーター

    args

    Python 呼び出し可能オブジェクトの位置引数またはキーワード引数。

  • 宣言

    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)...)