[Tutor] How to type annotate complex dictionary containing lambdas?

David L Neil PyTutor at DancesWithMice.info
Sun Nov 17 17:15:27 EST 2019


On 18/11/19 11:09 AM, Mats Wichmann wrote:
> On 11/17/19 12:46 PM, boB Stepp wrote:
> 
>> Apparently because of the lambda outside of the list, I apparently
>> must annotate them as "Callable". 
> 
> yup, you're right, I spaced out that bit when trying to definitively 
> tell you the value was either a str or a List.  Sigh...

There's another rule-of-thumb right there: if the parameter list 
consists of many and/or many different types of data, perhaps consider 
'another way'...


I've never tried an experiment (or, never found the need), but does mypy 
(or...) actually and effectively, look two- and three-deep into 
data-structures?

-- 
Regards =dn


More information about the Tutor mailing list