Iterators and Iterables in Python (How for Loop Actually Works?) #28

Поділитися
Вставка
  • Опубліковано 6 січ 2025

КОМЕНТАРІ • 39

  • @programizstudios
    @programizstudios  2 роки тому +1

    🔥 Learn Python with a more hands-on experience with Programiz PRO-interactive lessons, quizzes & challenges.
    Try Programiz PRO: bit.ly/right-python

  • @CreationTribe
    @CreationTribe 2 роки тому +3

    Gotta hand it to you - that was short, concise, and explained well. Thank you :)

  • @h44r96
    @h44r96 Рік тому

    The perfect video on Iterators exists. Thanks for the video. New sub ✌️

  • @arish.fxtbl1
    @arish.fxtbl1 2 роки тому

    brother i m like 9 yr old and i only understand from ur concepts and video even not by my own father! thanks a lot... hats off to you

  • @BJGunners
    @BJGunners 3 роки тому +11

    Hello,
    I am confused about the implementation of the custom iterator, you never used the __iter__ function to "initialize" the iterator as you would with the built in iter() function, and the custom __iter__ function doesnt return an iterator but an Even object.
    Also it compiled fine after removing the __iter__ function, i tought it was mandatory to have implemented the __iter__ function ?
    otherwise clear explanation

    • @iheartalgebra
      @iheartalgebra 3 роки тому +5

      You are correct that the ___iter___ method was not called. However, in this case the ___iter___ method just returns self, so there no point in using it: the Even object is already an iterator. So what makes an object an iterator? From StackOverflow: "Being an iterator" means "having a __next__(self) method", which the Even object has.

  • @pierrejacomet8098
    @pierrejacomet8098 3 роки тому +1

    Fantastic video. I like the cadence you use to teach the concepts. Kudos.

  • @alxcnwy
    @alxcnwy 3 роки тому +3

    Thanks for all your hard work - love your website and vids!

  • @ComputerScienceSimplified
    @ComputerScienceSimplified 4 роки тому +3

    Awesome video, keep up the amazing work! :)

  • @shivanandpatil3385
    @shivanandpatil3385 3 роки тому +1

    So easy and helpful ❤️ thank you so much ❤️

  • @los4776
    @los4776 3 роки тому

    Had to download the mobile app after a quality video like this

  • @Mxdy_
    @Mxdy_ Рік тому

    great vid, however I've a slight misunderstanding why do we return the result in the next function and not just return result * 2

  • @dileep2448
    @dileep2448 3 роки тому

    i have gone thru your website. its really nice.

  • @priyadangle
    @priyadangle 2 роки тому

    hello there is a slight confusion in the init method the argument are two but while initializing it there is self.n?

  • @sandipansarkar9211
    @sandipansarkar9211 3 роки тому +1

    great explanation

  • @adityabansod8493
    @adityabansod8493 2 роки тому

    Hello, thanks for the explanation. I have a question. In the "generators" video, you mention that the "return" statement destroys the state of the local variables whereas a yield keyword remembers the local variable state. When you instantiate an object of the class Even (numbers) in this video, and call next on this object, how does it remember the updated self.n value in the next call, if the return statement does not remember the state of the local variables? Thanks in advance.

  • @javiervaldez414
    @javiervaldez414 3 роки тому +1

    This it's a great explanation, you are amazing

  • @noweare1
    @noweare1 2 роки тому

    in a loop can you just use enumerate ? for i , v enumerate(things) i will keep track of the loop counts

  • @modinpatel8192
    @modinpatel8192 2 роки тому

    nice explaing bro

  • @patilvishu16
    @patilvishu16 3 роки тому

    Thanks for this video.. very helpful..

  • @ananthsb3955
    @ananthsb3955 4 роки тому +2

    Superb

  • @aliasgar215
    @aliasgar215 3 роки тому +1

    with dir(numbers) we can see methods in a module. How to see the code of that method. Is there any way to see code of __iter__ method

    • @sasidharnaidu4507
      @sasidharnaidu4507 2 роки тому

      U can't see the code using dir. For that u need to refer to official documentation. In python, most of the inbuilt functions r written using C.

  • @luznoceda423
    @luznoceda423 3 роки тому +2

    Will you teach us about multi-threading or multi-processing? :D

  • @htpps.Pratik
    @htpps.Pratik Рік тому

    Thumbnail 🔥😆

  • @shyamazure
    @shyamazure 3 роки тому

    Nice explanation

  • @cesararturocastanonacuna3325
    @cesararturocastanonacuna3325 3 роки тому

    The mobile App is unbelievably amazing.

  • @pandathegeneral2426
    @pandathegeneral2426 3 роки тому +1

    You are just too good ;-;

  • @javascript2409
    @javascript2409 4 роки тому

    Every time new thigs avalabe this chhanel

  • @tommy9x
    @tommy9x 3 роки тому

    Lost from self.n might need to to to Class lesson?

  • @trinib1
    @trinib1 4 роки тому

    a python god

  • @broyo2008
    @broyo2008 4 роки тому +4

    First here

  • @yanskievl3520
    @yanskievl3520 2 роки тому

    Honestly i don't know how can i use this in my program.

  • @OnedayIwillbuyREHimalayan400
    @OnedayIwillbuyREHimalayan400 3 роки тому +1

    Good explanation but you move your head alot

    • @DomUnseen
      @DomUnseen 3 роки тому +1

      left, right, left, right, left, right.... :D

    • @OnedayIwillbuyREHimalayan400
      @OnedayIwillbuyREHimalayan400 3 роки тому

      @@DomUnseen Lol yh, it hurt head

    • @certifiedsmartass4122
      @certifiedsmartass4122 2 роки тому

      Yeah and it annoys me. I cannot even look at the screen and focus when he talks. I mean turning left and right sometimes is fine, but the dude keeps doing it. Won't the cameraman say anything about it?