FAQ

On 8/25/2015 1:48 PM, Sven R. Kunze wrote:


I think the main issue here is the gab between intuition and what the
compiler actually does. The following line:

class MyClass: # first appearance of MyClass

basically creates MyClass in the mind of the developer reading this
piece of code.

I think the gap is less than you think ;-). Or maybe we think
differently when reading code. Both human and compiler create the
concept 'MyClass' (properly quoted) as an instance of the concept 'class'.


In a static language like C, types are only concepts in the minds of
programmers and compilers. There are no runtime char, int, float, or
struct xyz objects, only the names or concepts. When the compiler is
done, there are only bytes in a sense not true of Python.

Thus, he expects to be able to use it after this line.

One can use the string 'MyClass' in an annotation, for instance, and
eventually dereference it to the object after the object is created. A
smart type checker could understand that 'MyClass' in annotations within
the class MyClass statement means instances of the future MyClass object.


A developer should not expect to use not-yet-existent attributes and
methods of the object.




--
Terry Jan Reedy

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 20 of 28 | next ›
Discussion Overview
grouppython-ideas @
categoriespython
postedAug 24, '15 at 4:19a
activeAug 28, '15 at 7:21p
posts28
users10
websitepython.org

People

Translate

site design / logo © 2017 Grokbase