For those watching: please don’t use f-strings if you aren’t going to use the functionality of f-strings. Readability comes in to play here due to intent
i knew about Enums, but not about Flags ! Maybe i really should check the whole documentation of the enum package, it seems it haven't revealed all its best secrets yet !
I swear that when I was reading the docs a couple years ago I never noticed the Flag bit. Goes to show that re-reading the docs isn't always a bad idea!
I find I use StrEnum with auto() somewhat frequently, though its usefulness some would debate. It's nice to have one clear place to replace a string, rather than having trust my IDE to do a find/replace exactly where I want it.
I was watching this video and thinking kinda: "is it really python? It doesnt have match statement when i started to learn it and even after 3 years using it - it is a first time i meet usage of match
@@murphygreen8484I am an experienced python dev and really like code roasting/refactoring. I've always wanted to start a UA-cam channel just to do that. Would you like me to start with yours?
I mean… unless you want the words “ON” and “OFF” or something to be your return value or something… the joy of coding is there’s no universal truth and everything is subjective to one thing and one thing only: did it do what you wanted it to or not… I have lights that have 3+ states… ain’t no bool got that! Maybe a flag eh? EH? 😂
@@lukelauder5465 If i came across enums with on or off attached to them relating to the state of some class instead of using __repr__ or __str__ to represent that aspect of the class, id be in a bad way
Hey man, this video is great! I cant stop hearing you talk about Colas tho lol. Color is pronounced CUH-ler in the US and CUH-luh in the UK Thanks for the tutorial!
Thank you for finding us this info...However, Is enum really essential ? I am not able to comprehend why would it be needed ? Just for cleaner looking code ?
They are conceptually very similar. Flags define the "universe" of the set, allowing certain operations like complements while also restricting what they can contain. Flags are also immutable and cannot be nested, unlike regular Python sets.
Using flags allows you to store multiple states in a single integer, which makes it more efficient to save and query in a database, compared to using sets.
It’s too bad he didn’t catch himself on ALL not being 31 rather than 27 because black was included in all instead of blue! Ha! I totally feel that typo tho… UGH!
FYI 9:04 it auto completed to black instead of blue.
Interesting video. Thanks
I was fighting with autocomplete each time I wrote blue, and it still got me in the end!
Flag works like:
RED = 1 (001)
GREEN = 2 (010)
BLUE = 4 (100)
ALL = 7 (111) because 001 | 010 | 100 = 111
4 Bit Binary:D (but without the last)
@@minepoint2794So it’s 3 bit binary?
@@Nbrother1234 Yes, that. I actually didn't know that existed 💀🤦♂
Then PURPLE = 5?
How come?
python doing bitflags is nuts as heck. super awesome! i am ready to use it
i love bitflags
For those watching: please don’t use f-strings if you aren’t going to use the functionality of f-strings. Readability comes in to play here due to intent
I was just planning to dive in to Enums thanks man
i knew about Enums, but not about Flags ! Maybe i really should check the whole documentation of the enum package, it seems it haven't revealed all its best secrets yet !
I swear that when I was reading the docs a couple years ago I never noticed the Flag bit. Goes to show that re-reading the docs isn't always a bad idea!
I find I use StrEnum with auto() somewhat frequently, though its usefulness some would debate. It's nice to have one clear place to replace a string, rather than having trust my IDE to do a find/replace exactly where I want it.
I just learned about IntEnum & StrEnum, will have a video out on that soon :)
great coverage of enums, thank you!
I’m so glad python added match case
I was watching this video and thinking kinda: "is it really python? It doesnt have match statement when i started to learn it and even after 3 years using it - it is a first time i meet usage of match
Nice video 👍. Thank you !!
please do one video on how to dind difference between instance and library vs package vs module
You forget the IntEnum which makes it quite useful to be stored as an integer constant directly into the database.
а для чего делать наследование от Enum для строковых значений? для таких случаев имеется StrEnum
I don't understand what have you said but I am agree with you that StrEnum should be used there :)
Also IntEnum when you need integers
and also you can use bitwise
Awesome!!!!
I literally looked this up yesterday...
Hey Indently! Would you want to do a video refactoring someone's (mine) code?
Please refactor my code too 😂
are You guys real?
The code works and is a small program. Was thinking it could be like the code roasts that ArjanCodes does
@@murphygreen8484I am an experienced python dev and really like code roasting/refactoring. I've always wanted to start a UA-cam channel just to do that. Would you like me to start with yours?
I think you shouldn't use str as type hint to enum members?
a lamp turning on an off and only having two states is literally a perfect case for a boolean and explicitly not an enum
I mean… unless you want the words “ON” and “OFF” or something to be your return value or something… the joy of coding is there’s no universal truth and everything is subjective to one thing and one thing only: did it do what you wanted it to or not… I have lights that have 3+ states… ain’t no bool got that! Maybe a flag eh? EH? 😂
@@lukelauder5465 If i came across enums with on or off attached to them relating to the state of some class instead of using __repr__ or __str__ to represent that aspect of the class, id be in a bad way
Is boolean actually an Enum with 2 constants?
No
Hey man, this video is great! I cant stop hearing you talk about Colas tho lol.
Color is pronounced CUH-ler in the US and CUH-luh in the UK
Thanks for the tutorial!
Thank you for finding us this info...However, Is enum really essential ? I am not able to comprehend why would it be needed ? Just for cleaner looking code ?
It will save you from bugs, typos are common in programming.
Nice
Greate
What's the difference between using flags and sets?
They are conceptually very similar. Flags define the "universe" of the set, allowing certain operations like complements while also restricting what they can contain. Flags are also immutable and cannot be nested, unlike regular Python sets.
Using flags allows you to store multiple states in a single integer, which makes it more efficient to save and query in a database, compared to using sets.
9:02 you mistake blue with black (wrote black twice)
❤❤
What is enum?
| is neither union nor addition, it’s bitwise or.
It’s too bad he didn’t catch himself on ALL not being 31 rather than 27 because black was included in all instead of blue! Ha! I totally feel that typo tho… UGH!
indently ı think my lamb is possesed what do ı do
If your lamp is turned on without electricity, you sell it to scientists and become a billionaire
@@Indently oh really ımma do t- *gets assasinated
never used python
is python now statically typed language or smt ?
❤❤