SyntaxError: unqualified exec is not allowed in ... ?

Discussion in 'Python' started by j vickroy, Oct 8, 2003.

  1. j vickroy

    j vickroy Guest

    Could someone help me understand the following Python 2.3 error message:

    SyntaxError: unqualified exec is not allowed in function 'load' it contains
    a nested function with free variables

    in the following context:

    class Spam(object): pass

    class Spammer(object):
    ...
    def load(self):
    ...
    exec 'o = %s()' % Spam.__name__
    ...


    Thanks.

    P.S.
    I would provide a simple script demonstrating the problem, but, so far, I
    have not been able to reproduce the error in a simple context.
     
    j vickroy, Oct 8, 2003
    #1
    1. Advertising

  2. j vickroy

    j vickroy Guest

    OK-- never fails -- puzzle over something for a long period of time -- post
    message to group -- see cause of error soon after posting.

    There is a lambda expression further down the line in the function where the
    syntax error is raised.

    Sorry for the needless posting.

    "j vickroy" <> wrote in message
    news:bm1doh$if7$...
    > Could someone help me understand the following Python 2.3 error message:
    >
    > SyntaxError: unqualified exec is not allowed in function 'load' it

    contains
    > a nested function with free variables
    >
    > in the following context:
    >
    > class Spam(object): pass
    >
    > class Spammer(object):
    > ...
    > def load(self):
    > ...
    > exec 'o = %s()' % Spam.__name__
    > ...
    >
    >
    > Thanks.
    >
    > P.S.
    > I would provide a simple script demonstrating the problem, but, so far, I
    > have not been able to reproduce the error in a simple context.
    >
    >
     
    j vickroy, Oct 8, 2003
    #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. C. M. Sperberg-McQueen
    Replies:
    0
    Views:
    811
    C. M. Sperberg-McQueen
    Jul 31, 2003
  2. George Sakkis
    Replies:
    4
    Views:
    619
    Steven Bethard
    Jan 15, 2008
  3. Stef Mientki
    Replies:
    0
    Views:
    583
    Stef Mientki
    Oct 20, 2008
  4. Terry Reedy
    Replies:
    0
    Views:
    696
    Terry Reedy
    Oct 20, 2008
  5. Iñaki Baz Castillo
    Replies:
    13
    Views:
    504
    Iñaki Baz Castillo
    May 1, 2011
Loading...

Share This Page