Cell objects and their values

Discussion in 'Python' started by Robert Brewer, Apr 22, 2004.

  1. Say I obtain a cell object via:

    >>> def f():

    .... y = 3
    .... def g():
    .... return y
    .... return g
    ....
    >>> f().func_closure[0]

    <cell at 0x011787F0: int object at 0x002F9320>

    Is there a way to get the value of the int (f.y) which is referenced by
    the cell, without inspecting (or even having a reference to) f? That is,
    using only the object "g()" and its attributes, I'd like to obtain the
    same value for LOAD_DEREF that the interpreter does; in the same way
    that I can access g.func_globals, I'd like something similar to
    "g.func_cellvars" (not just the names as in g.func_code.co_cellvars, but
    the values)...


    Robert Brewer
    MIS
    Amor Ministries
     
    Robert Brewer, Apr 22, 2004
    #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. Richard Dixson
    Replies:
    1
    Views:
    522
    Joe Fallon
    May 18, 2004
  2. Richard Dixson
    Replies:
    2
    Views:
    739
    Richard Dixson
    May 18, 2004
  3. Jeff
    Replies:
    3
    Views:
    4,780
    Roedy Green
    Oct 11, 2003
  4. Robert Brewer

    RE: Cell objects and their values

    Robert Brewer, Apr 22, 2004, in forum: Python
    Replies:
    2
    Views:
    255
    Jeff Epler
    Apr 22, 2004
  5. Stefan Schwarzer

    Naming future objects and their methods

    Stefan Schwarzer, Apr 14, 2012, in forum: Python
    Replies:
    2
    Views:
    302
    Stefan Schwarzer
    Apr 16, 2012
Loading...

Share This Page