473,377 Members | 1,119 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,377 software developers and data experts.

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

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.
Jul 18 '05 #1
1 11773
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" <ji*********@noaa.gov> wrote in message
news:bm**********@boulder.noaa.gov...
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.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Attila Szabo | last post by:
Hi, I wrote this sample piece of code: def main(): lambda x: 'ABC%s' % str(x) for k in range(2): exec('print %s' % k) main()
0
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
1
by: Todd | last post by:
Hi, I'm working right from the example here to make a basic extenstion module. http://docs.python.org/ext/intro.html...
5
by: DIBS | last post by:
I'm new to Python and I don't understand what I'm doing wrong. I'm running windows xp. In the command line window, I type: Python Sudoku.py and I get the response" SyntaxError: invalid...
9
by: Mark Olbert | last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified,...
7
by: oscartheduck | last post by:
I have a small script for doing some ssh stuff for me. I could have written it as shell script, but wanted to improve my python skills some. RIght now, I'm not catching a syntax error as I'd...
4
by: George Sakkis | last post by:
Unless I missed it, PEP 328 doesn't mention anything about this. What's the reason for not allowing "from .relative.module import *' ? George
8
by: r0g | last post by:
Hi There, I'm trying to migrate a locally hosted page from windows to a private Ubuntu development server and one of the key bits of functionality (which used to work fine in Windows) was the...
0
by: Stef Mientki | last post by:
Terry Reedy wrote: The locals of the code block where the instance of this class is created. No I think it's indeed handled as function call. I now that, because the globals (and sometimes ??? the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.