I like to add that itertools has an accumulate function, that does the same but gives you an iterable for the inbetween values. It has minor differences: the place of the iterable and the function are switched and the inital value is a pure keyword argument, still nice to have it, so: print(list(accumulate(range(1, 6), lambda a, b:a+b, initial=20))) will print [20, 21, 23, 26, 30, 35].
Now with about a few years of experience doing Python professionally, I’d confidently say I would never use these kind of functions over list comprehension, for a few reasons. 1, they’re difficult to read and maintain. 2, they’re an extra functionality you’d need to import in. And 3, most importantly, rather than remembering these myriad of Python functions, it’s better to learn the core and use Google for the rest when and if you need.
How is this the same as list comprehensions? List comprehensions are surely for performing a function in a loop and generating a list, whereas this is generating a single value from an existing list.
@@DhavalAhir10 You should look up generators when used in list comprehension. And comprehension by itself doesn't eat up RAM, unless you have written a very poorly optimised loop.
please make a video about class methods and object methods(all kind of it ) and the differences between them just for clarification (and also usage of them in real situations) because the way you teach is amazing and thank you very much for your consideration
So you can very easy count the ! I don't know how to say in english but when you understand 2! = 2, 3! = 6 etc. In polish it's silnia, 2 silnia, 3 silnia itd.
Yes, you can easily calculate a factorial, although I think there are faster versions to do so. The important part is to understand the concept since it has many more applications other than factorial 😊
I use join to make a string out of a list of strings. Also I add format to do the same result as you got with "INIT". You have not persuaded me to use "reduce". :)
If you can use inbuilt functions that are simple (such as sum()), prioritise that, once you start programming something more complex than hello world, you might experience a use for reduce here and there :)
so I get massive data files from each orbit of a satellite. Since it orbits 9 times per day, I want to create a "daily output". This could be a real pain. I've seen the dog crap Matlab code ppl have tried: it's unmaintable. So I overload "
if you skipped all illegal moves in that chess game, the only legal move would be c3 (white's move). this is assuming that you still alternate when a move is skipped.
these type hints just clutter the code. No seriously. What if I want to reduce a list of np.poly1d instances, because I actually need hard math at work. I don't need a product function saying "I take floats", and I sure don't need floats if I am computing factorials. It's totally unpythonic. I mean what's next "fprintf"???? We need to keep this in check.
@@Indently Dude, I wouldn't stay subscribed if I generaly don't like the content, but I don't just troll around, you need consructive criticism sometimes, we all do, if people just praising you even is something is average, there is no room for grow. I generaly think you should put on few projects, why not, video quality is good and you know how to program, acually I like the way you write code more than neural nine (aside from type hinting 🙂)
Yeah I'm just kidding, I appreciate constructive criticism. I'm actually taking a break from posting projects to UA-cam because I've gotten a few copyright claims from AI that found "logos" in my projects. The official WhatsApp team filed a copyright claim since I had their logo in one of my videos (but it was filed by an AI, that scans videos). And there's absolutely no way to get around it, or even appeal to that. And the other time I made a video regarding some cyber security practises, UA-cam gave me a strike creating a video that showed "potentially harmful" material. I tried to appeal to that, but they refused that one as well. So I kind of got bummed out, which is why I respect NeuralNine, he got a few strikes and is still going strong! Maybe in the near future I will create more projects on this channel, but recently I've just been posting projects on my Udemy course.
Sir please explain class and objects with full details not in shorts please I am having exams to join a company which is having a big important question with class topic Please sir 🙏🙏🙏 it will help my career
Amazing video👏 I love map() filter() and reduce(), I use them every time I see an opportunity.
I was asked about them in my interview.
@@sabrysm how did it go?
@@dk-ww3kp It went well (although I was not familiar with them) but I got the offer!
Please use comprehensions instead, they're way more readable. map and filter give me flashbacks to my dark days of writing haskell.
most of the time, list/generator/dict/set comprehensions are better choice than map/filter.
I like to add that itertools has an accumulate function, that does the same but gives you an iterable for the inbetween values. It has minor differences: the place of the iterable and the function are switched and the inital value is a pure keyword argument, still nice to have it, so:
print(list(accumulate(range(1, 6), lambda a, b:a+b, initial=20)))
will print [20, 21, 23, 26, 30, 35].
Now with about a few years of experience doing Python professionally, I’d confidently say I would never use these kind of functions over list comprehension, for a few reasons.
1, they’re difficult to read and maintain.
2, they’re an extra functionality you’d need to import in.
And 3, most importantly, rather than remembering these myriad of Python functions, it’s better to learn the core and use Google for the rest when and if you need.
How is this the same as list comprehensions? List comprehensions are surely for performing a function in a loop and generating a list, whereas this is generating a single value from an existing list.
Don't use list comprehension, it will blast RAM of our computer. Takes so many memory.
@@DhavalAhir10 You should look up generators when used in list comprehension. And comprehension by itself doesn't eat up RAM, unless you have written a very poorly optimised loop.
@@ThatSayanGuy Generators is best idea.
please make a video about class methods and object methods(all kind of it ) and the differences between them just for clarification (and also usage of them in real situations)
because the way you teach is amazing and thank you very much for your consideration
I already did
So you can very easy count the ! I don't know how to say in english but when you understand 2! = 2, 3! = 6 etc. In polish it's silnia, 2 silnia, 3 silnia itd.
! = Factorial.
Yes, you can easily calculate a factorial, although I think there are faster versions to do so. The important part is to understand the concept since it has many more applications other than factorial 😊
@@elatedbento any factorial that is cpu limited is not going to fit into memory.
Just make your function a generator @@DrDeuteron
I use join to make a string out of a list of strings. Also I add format to do the same result as you got with "INIT". You have not persuaded me to use "reduce". :)
If you can use inbuilt functions that are simple (such as sum()), prioritise that, once you start programming something more complex than hello world, you might experience a use for reduce here and there :)
@@Indently No, I don't
Interesthing to know it exists, there is always alternative
so I get massive data files from each orbit of a satellite. Since it orbits 9 times per day, I want to create a "daily output". This could be a real pain. I've seen the dog crap Matlab code ppl have tried: it's unmaintable. So I overload "
@@DrDeuteron is FORTRAN any good?
Do you have an overall overview video on functools like itertools?
As a C programmer, this has broken my mind for a second. Then I realized there're no macroses and inline functions in Python
if you skipped all illegal moves in that chess game, the only legal move would be c3 (white's move). this is assuming that you still alternate when a move is skipped.
Functools does seem to be interesting, waiting for more videos on them
wraps, partial, total_ordering, lru_cache, cached_property...
YES!
Thank you for your video. I just wonder why you don’t have these on Facebook.
because Facebook is unpythonic in the extreme. I still can't believe Guido worked for The Borg.
I am starting using Python, and the difficulty that I have is to see the list command or function to make a study of each .Were to look for ?
RTFM.
read the manual.
"why_tho" read my mind🤣
I wish I could write these like
[1, 2, 3].map(lambda x: x*2).reduce(lambda a, b: a * b)
You can do nested list comprehensions, but I wouldn't recommend it lol.
do you mean:
>>>(2).__rpow__(reduce(operator.mul, [1, 2, 3]))
36
???
@DrDeuteron the result is the same, but the expression is not the same one.
if I change a * b to a + b, the result won't be the same.
@@voxelfusion9894 how do I change reduce to list comprehension?
@@sangchoo1201 operator.add
Basically std::accumulate
Accumulate also exists in python and it's different
not clear why it is better then "map" . what is difference ?
Map returns list
Iterable*
It actually returns a map object that works as an iterator, which is much more memory efficient.
Guido wants to get rid of map reduce
Guido wants to do many things ;)
these type hints just clutter the code.
No seriously. What if I want to reduce a list of np.poly1d instances, because I actually need hard math at work. I don't need a product function saying "I take floats", and I sure don't need floats if I am computing factorials. It's totally unpythonic. I mean what's next "fprintf"???? We need to keep this in check.
For a guy 3 years into python, you should consider showing us real projects on yt instead of just simple 3 line snippets
I recommend a channel called neuralnine for projects
@@Indently it's a decent channel, of all I follow I like best Mariya Sha on Python Simplified
Comment: My favourite channel is another channel
Indently: 🥲
@@Indently Dude, I wouldn't stay subscribed if I generaly don't like the content, but I don't just troll around, you need consructive criticism sometimes, we all do, if people just praising you even is something is average, there is no room for grow. I generaly think you should put on few projects, why not, video quality is good and you know how to program, acually I like the way you write code more than neural nine (aside from type hinting 🙂)
Yeah I'm just kidding, I appreciate constructive criticism. I'm actually taking a break from posting projects to UA-cam because I've gotten a few copyright claims from AI that found "logos" in my projects. The official WhatsApp team filed a copyright claim since I had their logo in one of my videos (but it was filed by an AI, that scans videos). And there's absolutely no way to get around it, or even appeal to that.
And the other time I made a video regarding some cyber security practises, UA-cam gave me a strike creating a video that showed "potentially harmful" material. I tried to appeal to that, but they refused that one as well. So I kind of got bummed out, which is why I respect NeuralNine, he got a few strikes and is still going strong!
Maybe in the near future I will create more projects on this channel, but recently I've just been posting projects on my Udemy course.
Sir please explain class and objects with full details not in shorts please
I am having exams to join a company which is having a big important question with class topic
Please sir 🙏🙏🙏 it will help my career
I have a full course at: indently.io
That's easily something you can look up