Comment before watching: Itertools has been a life-saver for a bunch of programming puzzles/challenges I've done recently, and I'm happy to see it get a moment in the spotlight!
Hi Tim, I've purchased programming expert IO a week back. So far I'm hooked on it and the fact that the tests gives you a bit of creative freedom makes solving the challenges a lot more fun. Thanks for the effort you put into your craft. It really means a lot for people like me who cant afford to go back to university.
I have to say this was 'magical'. So many itertool fuctions I did not know about explained well. So many times I could have been using itertools rather than loops.
That looks extremely useful! For the repeat and the chain (from_iterable) functions, I felt like they could be more easily achieved with comprehensions and simple list concatenation/appending. All, of that if the objects to be repeated would not be large enough as to worry about memory management. Is that the case or am I missing something? For a moment, I thought that the chain.from_iterable function could have some extra functionality by maybe "unpacking" a list within a list. But I tested and it was not the case: chain.from_iterable_example([[1, 2, 3], [4, 5, 6], [[7, 8, 9]]]) prints: [1, 2, 3, 4, 5, 6, [7, 8, 9]]
At 3:30, I think this is bad design. `for x in l` is usually interpreted as "for each item in l", a shorthand for a `for (int i = 0; i < l.size(); i++) {}` style loop. For me, coming from other languages, this would be an unexpected behaviour and I can imagine how it could lead to head-into-wall type bugs.
This video is worth watching even just for the iterator introduction alone Very important point at 8:00 left unmentioned. In the case of for vs while ALWAYS use for in python if you can over while. While is the more generic of them and running on python, for however is a highly optimized C-implementation that is a LOT faster and efficient than using while.
Hello brother i have been watching u for like more than 2 years but i wanna know how u manages to learn many languages like c++,pytjon ,js simultaneously.. and u also learning many algo.and otjer concepts along with them.. could u pls share your ideas how u mamage all. And stil be the best at many things
im new to python how can i make this work : class MyNumbers: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def __iter__(self): self.a = 1 return self def __next__(self): if self.a
If you're really into the iterable collections paradigm I'd recommend Java (8 and beyond) and Rust in that order. In my experience these are the best iteration languages currently. Pythons list comprehension is interesting but without method chaining I feel python iterables are a little too verbose and less readable at a glance. Map reduce type lambda methods give you prior knowledge before you even know what the code does and that's very important in functional programming where things get abstracted very quickly and iterations where things get nested quickly.
If all you want to do is print 1 to 10, then a simple for loop using range() is enough. for i in range(10): print(i+1) Or if you want it the more “pythonic” way, use list comprehension: print([(i+1) for i in range(10)])
@@adiaphoros6842 I thought pythonic meant there is generally one way and not half a dozen ways of doing the same thing - which fills up the print with useless knowledge
@@illegalsmirf From what I read “pythonic” means “idiomatic in python,” which to me means “removing for loops through built-in functions.” But, I don’t know what I’m talking about, since I rarely program “pythonically,” because I’m more used to C, C#, and Java.
Tim, too fast. Loading up pupils with stuff you know @ speed you narrate allows no time for their cognition i.e. internally comprehend and absorb new learning. Suggest building in breaks of some form, so they can process what is going on.
The only thing you need to do is remember a few hundred libraries with a few hundred functions each. That is indeed much simpler ;~). But it will be more readable: Answer: No, only for other people who prefer memorizing the same libraries and functions. I did a test and most of my testers agree that it looks more elegant but when you ask them what the code actually does you get fewer correct answers. But the performance is better if you do that. Answer: If you need performance you better skip Python altogether. But it has great function like permutations and combinations. Answer, when was the last time you actually programmed permutation or combinations of lists? Most programmers never use them. I more or less agree with Linus Torvalds that the C syntax is enough.