[Python-ideas] Better Type Hinting

Stefan Behnel stefan_ml at behnel.de
Fri Jun 5 15:11:47 CEST 2015


Cory Benfield schrieb am 05.06.2015 um 09:36:
>> On 5 Jun 2015, at 08:21, Thomas Güttler wrote:
>> 
>> I am using logger.warn() not logging.warn().
>> 
>> The question is: How to know which kind of duck "logger" is?
>> 
>> "logger" was created by "logging.getLogger(__name__)"
>> 
>> It is not the question how to implement better guessing in the IDE.
>> 
>> The basics needs to be solved. Everything else is "toilet paper
>> programming" (Ah, smell inside, ... let's write an wrapper ...)
> 
> This question is unanswerable unless you actually execute the code at
> runtime under the exact same conditions as you expect to encounter it.

That doesn't mean that it's impossible to find enough type information to
make an IDE present something helpful to a user. In all interesting cases,
the object returned by logging.getLogger() will be a logger instance with a
well-known interface, and tools can just know that.

Tools like Jedi and PyCharm show that this is definitely possible.

Stefan



More information about the Python-ideas mailing list