I was made mistake while Entering the code like (stopiteration...but the s should be caps ) after watching your comment I entered Caps S Now I Got the correct code without error thanks... 👍🥰
Can someone or Navin tell me this that why are we not converting that TopTen class object 'values' to iterator object i.e like values = iter(values) As you are not creating iterator object in last example how is __iter__ method getting called or how is it working without it. As far as i know if we create an object of class only init method gets performed without calling. Please Help me with this. And Cheers to your work Navin. Thank you very much
@prsh1989 for suppose, if u have a string list and then u r trying to check if the list contains one particular value then u need to use iterator to check whether that specific value is present or not. Let us consider another example, suppose u r building a well built structure and if u don't know the length of list or any collections then u need to use next method in iterator and fetch the values if the list contains values in list
Sir the video is a little bit confusing regarding creating an our own object of iterator My doubt is initial part of video we created our own iterator object that is it,then what is the difference
class TopTen: def __init__(self): self.num=1 def __iter__(self): return self def __next__(self): val=self.num self.num += 1 return val values = TopTen() for i in values: print(i) ------------ i'm getting error like: TypeError: 'TopTen' object is not iterable ------------ Could'u help me to fix this ?
Sir, At last when we call print values then we should two ones because of init function and other one is because of iter function but we are getting only one value of 1. I am not understanding this can you help me in this.
This is because the iter is storing the value of self and that is none other but 1 in beginning but when the next()is called the value of the value of the self.num became 2 which would be passed as self in iter next time (in the for loop)
hi sir,I don't have IT background ,completed B.Sc. Zoology in 2013, now keen to join IT field,so can I start my career in Python ? Are jobs available for fresher Python Developer in market? Could you please guide?
I really Want to thank you Navin Sir..My college faculty never focus on the concepts of programming they are just making us rattutota... Thank you so much sir for coming on youtube and helping the students
internally the list is an iterator that has next and iter methods implemented and that's why you could use the for loop in list. What Navin teaches is you could create your own custom iterator
first example in list: values are repeated but while creating our own iterator values not repeated why this is happen plzz give me the difference of this scenario
In first example with list, if you observe carefully, he is performing for loop on the list object not on the iterator (it). If you perform for loop on "it" it would continue from where you left using "it.__next__()" function.
Under the def __iter__() method, why are we returning self only? And what does he mean by 'returning the object' when using this method? It's just a self keyword with no parameters. What does this mean? Please help
I really want to Thank you Sir for all the efforts and also for your nice energy, I hope that you still have this awsome energy and vibes, God bless you !!!
Im sorry to say your explanation is becoming staler and actually complicates the concepts,for the last 3 videos including this one .i had to go to another video and learn it and comeback here.i hope i don't have to do that every video from now on
sir!!!! in the before example u have shown the repeation of values getting in output...but in this example why it is not repaeting 1 and taking next values......
Sir, where have you learnt all this stuff . I am watching the whole series,your concepts are strong. Can you please tell me which course or way should I choose , For web development via. Python. I am cs student. 2nd yr
The way sir explain things is clear that its his past over all experience and strong understanding of OOPs, The reason i said this because every developer has its own way to clear concepts, Maybe you clear your concepts by watching or reading other videos or book.
I just debug and found how that statement for i in values just calls the next function in Topten class , every time after printing the value of i . This is awesome . You should include a debug session in this video itself.
It will be very very gladful if you give sometime in answering the good questions asked by us. Because we get into some confusion whose answers are not available on google. Then we got stucked there. So please at least give us any opportunity to get the confusion clear in between 2 days so that we will also don't lose the interest in clearing the questions. If you don't have that much time then you can also answer only necessary and tough questions.
agree.. but thing is not everyone read comments or those who read dont go deep down in comment section, Just like i replied your comment after one year lol
I still can't seem to comprehend the word iterate, aswell when he says it 'loops' over. I would really appreciate if anyone could dumb down the explanation as much as possible I'm desperate to understand this concept lol. Thank you in advance
modified iterators form where to start and where to stop: class ur_choice: def __init__(self, num): self.nums = int(input('enter from where to start')) def __iter__(self): return self def __next__(self): if self.nums
To be honest i understood this better from u sir in comparison to code with harry ,i m not comparing but actually u r a little better in explaining , don't kill me code with harry fans i am also his fan it's just my opinion
What happens if we print(next(it)) beyond the range of list? I mean what if we use print statement 6 time if the list has only 5 values? And can we access the index of an element using iter() and next()?
what is the use i dint understand when u want to print one by one it is done in 1st example bt in 2ns e ample own iterator all numbers are printed at once not as u told one by one dint understand what’s the real use u want to tell sir
@@telugutravellerraj You first have to define a class named Str and define init method which takes in a string ... Remember the case sensitivity And it still won't output yellow ... It will print the object itself
concept is extremely good no doubt on that, but your new look does not matching with personality..... but really your teaching style is awesome, thank god that you are providing such valuable knowledge with free of cost...