<div dir="ltr">It's "class variable" because we (at least I) also routinely use "instance variable".<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 16, 2017 at 4:23 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Since PEP 526 is already provisionally accepted, it may be too late to<br>
bring this up, but I have a question and suggestion about the name<br>
ClassVar. I've read the PEP but didn't see an answer or rejection to<br>
this.<br>
<br>
<a href="https://www.python.org/dev/peps/pep-0526/" rel="noreferrer" target="_blank">https://www.python.org/dev/<wbr>peps/pep-0526/</a><br>
<br>
Why choose ClassVar over ClassAttr when the usual terminology used in<br>
the Python community is class and instance *attributes* rather than<br>
"variables"?<br>
<br>
I understand that, in a sense, attributes are variables (unless they're<br>
constants *wink*) but the term "class variable" sounds very Java-esque<br>
rather than Pythonic. And it is an uncomfortable fit with a language<br>
like Python where classes are first class values like ints, strings,<br>
floats etc:<br>
<br>
- we talk about a string variable meaning a variable holding a string;<br>
- a float variable is a variable holding a float;<br>
- a list variable is a variable holding a list;<br>
- so a class variable ought to be a variable holding a class.<br>
<br>
I get the intention: we have local, global, instance and class<br>
variables. But I feel that grouping instance/class with local/global is<br>
too abstract and "computer sciencey": in practice, instance/class vars<br>
are used in ways which are different enough from global/local vars that<br>
they deserve a different name: attributes, members or properties are<br>
common choices.<br>
<br>
(Python of course uses attributes, and properties for a particular kind<br>
of computed attribute.)<br>
<br>
This introduces split terminology: we now talk about annotating class<br>
attributes with ClassVar. Since there's no GlobalVar, NonLocalVar or<br>
LocalVar, there doesn't seem to be any good reason to stick with the<br>
FooVar naming system.<br>
<br>
Can we change the annotation to ClassAttr instead?<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Steve<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>