Похожие чаты

Thought on this?

3 ответов

7 просмотров
Shahin-LA Автор вопроса

Here is kind of answer why this happen. I'm wondering why Gudio make this design decision https://stackoverflow.com/questions/11732329/boolean-testing-a-list-in-python

I'm all for choice. It's not like the language itself is forcing devs to use these checks. I like the idea of "truthiness" for arbitrary types. You just have to have sane and consistent defaults for that. From what I've seen, most non boolean types are "False", when they're not in a useful state. I think that's alright. For me it's the same as with the other kinds of magic python does behind the scenes: You have to know what it does and never just rely on you gut feeling. If you use it correctly, you can write short and readable code.

Common lisp does the same thing

Похожие вопросы

Обсуждают сегодня

Карта сайта