I love assert

Ethan Furman ethan at stoneleaf.us
Wed Nov 12 00:38:00 CET 2014


On 11/11/2014 03:02 PM, Peter Cacioppi wrote:
> On Tue, Nov 11, 2014 at 12:57 PM, TP wrote:
>>
>> PyCharm uses docstrings to accomplish the same task [2] but can also use asserts/isinstance [3].
>>
>> [2] https://www.jetbrains.com/pycharm/webhelp/type-hinting-in-pycharm.html
>> <https://www.jetbrains.com/pycharm/webhelp/type-hinting-in-pycharm.html#d232466e456>
>
> I use PyCharm. Thanks for [2], it's a keeper

Please, please don't use isinstance when you don't need to.  It just makes your code unusable to anybody who wants/needs 
to use a different-yet-compatible type than the one you checked for.

--
~Ethan~



More information about the Python-list mailing list