Re: Closures

Discussion in 'Python' started by Michael Sparks, Apr 29, 2004.

  1. On Thu, 29 Apr 2004, Gustavo Niemeyer wrote:

    > class Closure:
    > def __init__(self):
    > self.__dict__ = sys._getframe().f_back.f_locals


    Out of interest how portable is this? Strikes me as extremely useful
    class to have lying around :) The only thing that makes me wonder is the
    access to _getframe...


    Michael
     
    Michael Sparks, Apr 29, 2004
    #1
    1. Advertising

  2. Michael Sparks

    Robert Kern Guest

    Michael Sparks wrote:

    > On Thu, 29 Apr 2004, Gustavo Niemeyer wrote:
    >
    >
    >>class Closure:
    >> def __init__(self):
    >> self.__dict__ = sys._getframe().f_back.f_locals

    >
    >
    > Out of interest how portable is this? Strikes me as extremely useful
    > class to have lying around :) The only thing that makes me wonder is the
    > access to _getframe...


    Well, Guido considers "anything that uses sys._getframe() to be a danger
    to society unless proven innocent," but what does he know? ;-)

    http://article.gmane.org/gmane.comp.python.devel/58837

    > Michael


    --
    Robert Kern


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
     
    Robert Kern, Apr 30, 2004
    #2
    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. Kasper B. Graversen

    Closures in python

    Kasper B. Graversen, Sep 18, 2003, in forum: Python
    Replies:
    11
    Views:
    728
    David Eppstein
    Sep 21, 2003
  2. Gustavo Niemeyer

    Closures

    Gustavo Niemeyer, Apr 29, 2004, in forum: Python
    Replies:
    1
    Views:
    348
    Michele Simionato
    Apr 30, 2004
  3. Alexander May

    Misunderstanding about closures

    Alexander May, Jun 7, 2004, in forum: Python
    Replies:
    14
    Views:
    611
    Jacek Generowicz
    Jun 17, 2004
  4. Robert Brewer

    RE: Misunderstanding about closures

    Robert Brewer, Jun 7, 2004, in forum: Python
    Replies:
    1
    Views:
    437
    Hung Jung Lu
    Jun 7, 2004
  5. Jacek Generowicz

    Recoding closures in C

    Jacek Generowicz, Jun 10, 2004, in forum: Python
    Replies:
    0
    Views:
    296
    Jacek Generowicz
    Jun 10, 2004
Loading...

Share This Page