[Python-ideas] PEP 526: why ClassVar instead of ClassAttr?

Nick Coghlan ncoghlan at gmail.com
Wed May 17 07:14:58 EDT 2017

On 17 May 2017 at 19:03, Steven D'Aprano <steve at pearwood.info> wrote:
> On Tue, May 16, 2017 at 10:11:31PM -0700, Guido van Rossum wrote:
>> There was another reason too. Many things are "class attributes" e.g.
>> methods, descriptors. But only specific things are class *variables*.
> Ah, that's a good reason. I can live with that.

In the specific context of type hints, there is also
https://docs.python.org/3/library/typing.html#typing.TypeVar, which is
used to indicate that particular variable name refers to a type
variable for generics, rather than a normal runtime value. So a "type
variable" and a "type attribute" are also very different things
(assuming that the latter is being used as an equivalent to "class


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list