#๐Ÿ”’ Help with iterators

30 messages ยท Page 1 of 1 (latest)

dry wing
#

So I have an iterator for a BFS traversal and I have 2 options that both work but I just want to know which one is better to use and if they are the same (even tho they print the correct things)

rocky mistBOT
#

@dry wing

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dry wing
rocky mistBOT
clear bloom
dry wing
rocky mistBOT
dry wing
#

Yeah was about to send them

#

these being in next()

clear bloom
dry wing
#

like creating a generator?

clear bloom
#

yeah

dry wing
#

well yeah I could, but this is the assignment

#

and plus I'm still curious if there is a difference

clear bloom
# dry wing

oh by the way, next automatically calls self.__next__()

clear bloom
#

they're both just iterators

dry wing
#

well one has a loop in it and the other is like recursive

clear bloom
#

linear might be slightly better than recursive but this is python

#

pick the one thats more readable to you

dry wing
#

oh I see

#

that was my biggest curiosity

#

thank you very much

#

.close

left mauveBOT
#
Did you mean:
clear bloom
dry wing
#

!close

rocky mistBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.