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>
|
</div>
|
||||||
|
|
||||||
<p>
|
<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>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang">
|
<div class="targetlang">
|
||||||
|
|
@ -1616,7 +1616,7 @@ In Python, the static member can be access in three different ways:
|
||||||
>>> example.Spam_foo() # Spam::foo()
|
>>> example.Spam_foo() # Spam::foo()
|
||||||
>>> s = example.Spam()
|
>>> s = example.Spam()
|
||||||
>>> s.foo() # Spam::foo() via an instance
|
>>> 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>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -1627,16 +1627,31 @@ last technique is only available in Python-2.2 and later versions.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Static member variables are currently accessed as global variables. This means,
|
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>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang">
|
<div class="targetlang">
|
||||||
<pre>
|
<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
|
7
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</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>
|
<H3><a name="Python_nn21">33.3.8 C++ inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue