[Python-de] name2type mapping
Thomas Güttler
guettliml at thomas-guettler.de
Mo Okt 29 04:03:01 EDT 2018
Am 26.10.18 um 15:45 schrieb Marco Bakera:
> Thomas Güttler schrieb am 26.10.18 um 14:23:
>>
>>
>> Am 26.10.18 um 13:05 schrieb Marco Bakera:
>>>
>>> Mich würden drei Dinge interessieren:
>>>
>>> 1. Welches Problem wird gelöst?
>>
>> Obige URL zeigt einen englischen Text der wenige Wörter lang ist.
>> Was ist an "Better type-hints in IDEs." unverständlich?
>
> Den Text hatte ich gelesen. "Better type-hints" beschreibt aber kein
> Problem, das gelöst werden soll und klang für meinen Geschmack zu
> generisch. In welcher Hinsicht soll denn etwas verbessert werden? Was
> fehlt bei den derzeitigen Type-Hints? Und wurde dieser Aspekt beim
> Entstehen von PEP 484 bereits diskutiert?
Ich habe mal ein Beispiel hinzugefügt:
https://github.com/guettli/python-name2type-mapping/#use-case-example
{{{
Use Case Example
Your code base contains a variable name "request" 100 times, and in 70 times the variable type is an instance of
"django.http.HttpRequest" (detected by usual type annotations). If you want to have valid type information of all
occurences of "request" in your code, then you need to find a solution for 30 usages. You could annotate the variable in
your code 30 times (once per method). Or you could define a name2type mapping in the __init__.py file if your code.
}}}
Was ist nun noch unklar?
Gruß,
Thomas
--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines
Mehr Informationen über die Mailingliste python-de