Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027936
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:09:29+00:00 2026-05-20T11:09:29+00:00

I have been working in Python for a few months now, and it has

  • 0

I have been working in Python for a few months now, and it has occurred to me that I often overlook vocabulary that escapes me at first glance, instead trying to get the gist of an idea. Now, looking back, I still find myself confused beyond belief at what the term consume refers to. My initial interest came from explanations of iterators which spoke of a value of an iterator being consumed. However, looking around, this does not seem to be commonplace in the Python lexicon. Or is it? Digging around here finds mostly references to Web Services, and one or two discussions on how to hide this or that result of a function.

I suppose then, to break down my ignorance into a few base points:

  1. Does “consuming” do different things in different Pythonic contexts?
  2. What happens to data when it is consumed, such as in iter()?
  3. When a variable is assigned to an iterator’s result– the allegedly consumed piece of data– does it no longer belong to the iterator?
  4. Can you consume more than one value from an iterator object in a single call to the iterator?

I hope that makes some sort of sense. Note that this is not in reference to any particular need; I’m simply confused beyond rational plausibility.

EDIT: One more thing… does an iterated value (when called with next()) stay in memory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:09:30+00:00Added an answer on May 20, 2026 at 11:09 am

    Concerning 2.

    In fact, we must distinguish two cases.

    Remember what Greg Hewgill wrote:

    An “iterator” is a single object that is responsible
    for creating some sequence of elements.
    This sequence might be elements of an existing list,
    or it might be something calculated, like prime numbers
    or the decimal digits of π.

    First case:

    the iterator calculates the object that it must produce when stimulated; that is to say, the produced object wasn’t existing before the call of next() . Consequently, if a name is assigned to the object, this latter will survive; if not , the object will exist without being binded to a name in a namespace during a certain time, and then it will vanish in the memory, that is to say the bits it occupies will be used for another object later or sooner.

    The second case

    is when the iterator returns formerly existing objects belonging to a list, a tuple, a dictionary, etc.. In this case, each object produced by a next() had already a binding with a name. Then if the object is assigned to a new name when it “pops” out of the iterator, there will be two names binded to the object. And if the object is not assigned to a name, it will continue to be binded to only one name, what is sufficient to maintain the object alive.

    In common:

    Each time an object is produced by a call of an iterator, if no name is assigned to him, the only result of the operation is that the iterator has been “consumed”. It’s a manner to say that even if there is no permanent consequence after the production of an object, it has happened something that let a trace inside the iterator.

    One speaks of consuming the iterator when a name is assigned to the object, too, however, I don’t want to confuse.

    Note:

    In fact, in case of an object pre-existing in a list, say, it may be that it had no name. But the list holds a reference of every object it “contains”… In fact a list doesn’t “contains” objects, but only references to objects… Well that goes beyond what I wanted to say.

    .

    Concerning 3

    You should’nt write 3: “When a variable is assigned to …”

    The word variable is a pitfall in Python because it has an ambiguous signification. There are no variables in Python, in the common sense known in other langages, that is to say a « delimited portion of memory whose value can change ». There are only objects. The word variable is habitually used to mean an identifier. So it is a better practice to call it identifier, or name. This avoids confusion.

    .

    Concerning 4

    I don’t think that it’s possible to obtain two returns from the iterator with only one call next()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working as a native C++ programmer for last few years. Now
I have recently been working with Python using Komodo Edit and other simpler editors
I have been working with a string[] array in C# that gets returned from
I have been working on some legacy C++ code that uses variable length structures
I have been working with relational databases for sometime, but it only recently occurred
I have been programming using Python for slightly more than half an year now
I have been trying to use the new validators that are now included with
I have been working on the problems presented in Python Challenge . One of
I've got a django project working on a development server(ubuntu) that we have been
I have been trying for several hours now to get sorl-thumbnail working, but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.