From 1ee0ac8e2a6f05aa1a326fdd60da8c0138bd2558 Mon Sep 17 00:00:00 2001 From: Andrii Medvediev <42775640+Andrew1Medvedev@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:14:22 +1100 Subject: [PATCH] New PyModule Set method --- src/runtime/PythonTypes/PyModule.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/runtime/PythonTypes/PyModule.cs b/src/runtime/PythonTypes/PyModule.cs index 243f77ecc..bb539373d 100644 --- a/src/runtime/PythonTypes/PyModule.cs +++ b/src/runtime/PythonTypes/PyModule.cs @@ -59,6 +59,22 @@ internal PyModule(BorrowedReference reference) : this(new NewReference(reference { } + /// + /// Set Variable Method + /// + /// + /// Add a new variable to the variables dict if it not exist + /// or update its value if the variable exists. + /// + public PyModule Set(string name, object? value, Type type) + { + if (name is null) throw new ArgumentNullException(nameof(name)); + + using var _value = Converter.ToPython(value, type); + SetPyValue(name, _value.Borrow()); + return this; + } + /// /// Given a module or package name, import the module and return the resulting object. /// pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy