Re: RuntimeError: dictionary changed size during iteration

Discussion in 'Python' started by Terry Reedy, Jan 20, 2005.

  1. Terry Reedy

    Terry Reedy Guest

    RE: RuntimeError: dictionary changed size during iteration
    "Batista, Facundo" <> wrote

    [Robert Brewer]
    #- But not unexpected, since vars() returns a dictionary, and
    #- binding 'e'
    #- changes that dictionary while you are iterating over it.

    >For me, the point is: vars() returns the local variables
    > as a list or is a generator?


    As the OP said, it returns a *dictionary*. In particular:

    >>> help(vars)

    Help on built-in function vars:

    vars(...)
    vars([object]) -> dictionary

    Without arguments, equivalent to locals().
    With an argument, equivalent to object.__dict__.

    >In the docs don't say nothing about this.


    You must be having a bad day ;-). From Lib Ref 2.1 Built-in Functions:

    vars( [object])

    Without arguments, return a dictionary corresponding to the current local
    symbol table. With a module, class or class instance object as argument (or
    anything else that has a __dict__ attribute), returns a dictionary
    corresponding to the object's symbol table. The returned dictionary should
    not be modified: the effects on the corresponding symbol table are
    undefined

    Terry J. Reedy
    Terry Reedy, Jan 20, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roman Suzi
    Replies:
    0
    Views:
    327
    Roman Suzi
    Jan 19, 2005
  2. robert
    Replies:
    29
    Views:
    1,050
    Raymond Hettinger
    Mar 14, 2006
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    364
    Jean-Paul Calderone
    Mar 13, 2006
  4. Robert Dailey
    Replies:
    6
    Views:
    381
    Terry Reedy
    Dec 9, 2008
  5. Laszlo Nagy
    Replies:
    3
    Views:
    363
    John Nagle
    Apr 22, 2011
Loading...

Share This Page