[Python-ideas] pep-0484 - Forward references and Didactics - be orthogonal
Prof. Dr. L. Humbert
humbert at uni-wuppertal.de
Tue Aug 25 18:01:17 CEST 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 25.08.2015 17:15, Terry Reedy wrote:
> You did not say why you think this is bad. Is it a) students have to
> type "'"s?, or b) the resulting annotations are strings instead of the
> class?
Ok, the answer for short: a)
Pls let me explain it a bit:
> As you should know, at least after reading previous responses, making
> this work would require one of two major changes to Python class
> statements.
1st class pedagogical/didactical thinking …
Consider: there are recursive defined ADTs and we want to enable
students to understand concepts and produce python-code to realize, what
they understood.
The main point:
if the students already understood, that it is possible to place type
hints to place type hints for arguments and results of functions/methods
they should be able to reuse the notation in an orthogonal manner.
For example:
>>> def b (first: int, second: str) -> List[bool]:
... print(first)
... return [second.find(str(first))>=0]
...
>>> b(34, "Die 13 langen Nasen rauben ihm (34J) den Schlaf")
34
[True]
>>>
When it comes to recursive ADTs they should be able to write
>>> class Tree:
... def __init__(self, left: Tree, right: Tree):
... self.left = left
... self.right = right
TNX
Ludger
- --
https://twitter.com/n770
http://ddi.uni-wuppertal.de/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAlXckU0ACgkQJQsN9FQ+jJ+zGgCdHZvnTcM5H4YMGVa/S0hv/c2o
g8IAn2ZEFy8sL0f8uZDnzr1yFcFHc3A+
=Ex97
-----END PGP SIGNATURE-----
More information about the Python-ideas
mailing list