[pygobject] [gi] Add docstring to GLib.Variant constructor
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] [gi] Add docstring to GLib.Variant constructor
- Date: Wed, 26 Jan 2011 18:04:20 +0000 (UTC)
commit d3e30e240fed6ef1dd40fd29fd13dc2effc6c7b1
Author: Martin Pitt <martin pitt ubuntu com>
Date: Wed Jan 26 19:03:48 2011 +0100
[gi] Add docstring to GLib.Variant constructor
gi/overrides/GLib.py | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 3ef0483..e625328 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -166,6 +166,17 @@ class _VariantCreator(object):
class Variant(GLib.Variant):
def __new__(cls, format_string, value):
+ '''Create a GVariant from a native Python object.
+
+ format_string is a standard GVariant type signature, value is a Python
+ object whose structure has to match the signature.
+
+ Examples:
+ GLib.Variant('i', 1)
+ GLib.Variant('(is)', (1, 'hello'))
+ GLib.Variant('(asa{sv})', ([], {'foo': GLib.Variant('b', True),
+ 'bar': GLib.Variant('i', 2)}))
+ '''
creator = _VariantCreator()
(v, rest_format, _) = creator._create(format_string, [value])
if rest_format:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]