Update docs - python static members access
[skip-ci]
This commit is contained in:
parent
bfdbcdcf1a
commit
7a65f028f8
1 changed files with 19 additions and 4 deletions
|
|
@ -1608,7 +1608,7 @@ public:
|
|||
</div>
|
||||
|
||||
<p>
|
||||
In Python, the static member can be access in three different ways:
|
||||
In Python, the static member can be accessed in three different ways:
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
|
|
@ -1616,7 +1616,7 @@ In Python, the static member can be access in three different ways:
|
|||
>>> example.Spam_foo() # Spam::foo()
|
||||
>>> s = example.Spam()
|
||||
>>> s.foo() # Spam::foo() via an instance
|
||||
>>> example.Spam.foo() # Spam::foo(). Python-2.2 only
|
||||
>>> example.Spam.foo() # Spam::foo() using Python-2.2 and later
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -1627,16 +1627,31 @@ last technique is only available in Python-2.2 and later versions.
|
|||
|
||||
<p>
|
||||
Static member variables are currently accessed as global variables. This means,
|
||||
they are accessed through <tt>cvar</tt> like this:
|
||||
they are accessed through <tt>cvar</tt> or via an instance property:
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
>>> print example.cvar.Spam_bar
|
||||
>>> example.cvar.Spam_bar # Spam::bar
|
||||
7
|
||||
>>> s = example.Spam()
|
||||
>>> s.bar # Spam::bar via an instance property
|
||||
7
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The <tt>-builtin</tt> option uses a metaclass to additionally provide access as follows:
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
>>> example.Spam.bar # Spam::bar using -builtin option only
|
||||
7
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<H3><a name="Python_nn21">33.3.8 C++ inheritance</a></H3>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue