what is a boolean trap? (programming antipattern) (beginner - intermediate) anthony explains #204

preview_player
Показать описание
today I talk about a boolean trap, how you can spot one in code review, and how you can fix the problem using a few python features!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

Why not just define two functions - pop_first and pop_last?

StopThatShitPls
Автор

I am waiting for the sequel: "what is a troolean trap?" 🤣

jurgengmach
Автор

Do you know if there exists a tool to detect boolean traps? e.g. flake8 extension, or even a tool to re-write them. If not, I'm tempted to try writing one

marco_gorelli
Автор

Is there an advantage to using an Enum over typing.Literal?

Cpernicus
Автор

I haven't seen someone use the enum.Enum constructor like that before -- I usually see people write a class that inherits from Enum, then defines a bunch of class attributes like Tomato = "TOMATO", Lettuce = "LETTUCE", etc. Is using the enum.Enum primary constructor directly (like enum.Enum("Tomato") the same as writing a class that inherits from Enum with class attributes like Tomato = "Tomato"? I really need to look at how enums actually work under the hood :)

_gunna
Автор

I'd assume dct.popitem(True) would pop (3, 4). Because if a method called popitem takes any argument, it should be an integer index.
In my projects I just have unlimited line length, and never use positional arguments for anything unless some module (often pygame) forces me to.

teslainvestah
Автор

great video, but why write code in terminal as opposed to a lightweight editor like vscode which is easier to do ?

darrenlefcoe