Update docs - python static members access

[skip-ci]
This commit is contained in:
William S Fulton 2021-10-20 11:51:17 +01:00
commit 7a65f028f8

View file

@ -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:
&gt;&gt;&gt; example.Spam_foo() # Spam::foo() &gt;&gt;&gt; example.Spam_foo() # Spam::foo()
&gt;&gt;&gt; s = example.Spam() &gt;&gt;&gt; s = example.Spam()
&gt;&gt;&gt; s.foo() # Spam::foo() via an instance &gt;&gt;&gt; s.foo() # Spam::foo() via an instance
&gt;&gt;&gt; example.Spam.foo() # Spam::foo(). Python-2.2 only &gt;&gt;&gt; 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>
&gt;&gt;&gt; print example.cvar.Spam_bar &gt;&gt;&gt; example.cvar.Spam_bar # Spam::bar
7
&gt;&gt;&gt; s = example.Spam()
&gt;&gt;&gt; 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>
&gt;&gt;&gt; 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>