[Python-ideas] pep-0484 - Forward references and Didactics - be orthogonal

Prof. Dr. L. Humbert humbert at uni-wuppertal.de
Fri Aug 28 21:21:23 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 28.08.2015 15:58, Petr Viktorin wrote:
…
>> It is indeed possible to run the following code
>> /
>> from typing import List
>> class Tree:
>>      def __init__(self, left: 'Tree', right: 'Tree'):
>>          self.left = left
>>          self.right = right
>>      def leaves(self) -> List['Tree']:
>>          return []
>> def greeting(name: 'str') -> 'str':
>>      return 'Hello ' + name
>> \
>>
…
pv> You can put the entire hint in a string:
pv> def leaves(self) -> 'List[Tree]':

TNX … solves the problem in this example and makes it
orthogonal.

Next showstopper will come, when working on/with datastructures, which
contains entangled class-structures, perhaps the instantiation of a
class, when we have to use

	self.node = Node(…)
but not
	self.node= 'Node'(…)

So I think, we as educators have to live with this pedagogical
»suboptimal« solution(s) and have to communicate those non-orthogonal
notation and make clear, what the reason is all about.

	TNX
	Ludger

- -- 
https://twitter.com/n770
http://ddi.uni-wuppertal.de/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlXgtLMACgkQJQsN9FQ+jJ+4cgCfTaer3dFG4CscmNu/yo4AWxti
0AQAoI9nyTaA2hgDfyCEFk5WdkW1/28L
=Wp9U
-----END PGP SIGNATURE-----


More information about the Python-ideas mailing list