473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Don't understand syntax error: unqualified exec is not allowed ..

hello,

I've syntax error which I totally don't understand:

########## mainfile :
import test_upframe2

if __name__ == '__main__':
var1 = 33
code = 'print var1 + 3 \n'
test_upframe2.D o_Something_In_ Parent_NameSpac e ( code )

########### file = test_upframe2 :
class Do_Something_In _Parent_NameSpa ce ( object ) :
def __init__ ( self, code ) :

def do_more ( ) :
nonvar = [3,4]
while len ( nonvar ) 0 : # <<<===
nonvar.pop() # <<<===

import sys
p_locals = sys._getframe(1 ).f_locals
p_globals = sys._getframe(1 ).f_globals
try :
exec ( code, p_globals, p_locals )
except :
print 'ERROR'
gives me:
SyntaxError: unqualified exec is not allowed in function '__init__' it
contains a nested function with free variables (gui_support.py , line
408)

"unqualifie d exec" : I thought that meant there is some ambiguity in the
namespace, but I explictly definied the namespace

The function "do_more" is never called, so what does it matter what's
in there ?

If I remove the while-loop (which of course I can't) the syntax error
disappears.

I can place the function either as a class method or as a normal
function outside the class,
which both works well.
But I want the method / function not to be hidden.

Why does the above syntax error appear ?
Are there other ways to hide the function ?

thanks,
Stef Mientki
Oct 20 '08 #1
0 1780

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

Similar topics

3
3945
by: kepes.krisztian | last post by:
Hi ! In Unifying types and classes in Python 2.2 article I see that: >>> print a # show the result
1
38588
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
4
22150
by: matt hegarty | last post by:
Hi I am relatively new to XML, but am having problems with a validation issue. When the XML is parsed and validated using Xerces, the following error is seen: cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'questionFeed'.
6
2457
by: Ivan Shevanski | last post by:
Here's a noob question for everyone (I'm not sure if my first message got through, is had a "suspicious header" so sorry for double post is so), is there a way to turn off syntax warnings or just make them not visible? Thanks, -Ivan _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE!
1
11246
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." Explaining you the scene is the following Stored Proc.
127
5504
by: bz800k | last post by:
Hi Does this code satisfy ANSI C syntax ? void function(void) { int a = 2; a = ({int c; c = a + 2;}); /* <<-- here !! */ printf("a=%d\n", a);
4
3574
by: gregpinero | last post by:
It's the strangest thing, I'm pulling some text out of a MySQL table and trying to run exec on it, and it keeps giving me a syntax error, always at the end of the first line. Thanks in advance for any help. I'm really stuck on this one! -Greg I'm not sure what information would be most useful but here's a start:
2
1509
by: sva0008 | last post by:
I am writing a dynamic query insert into Tablename select '1111', name,address,phone,'1111', exec usp_storedProcedureName '1111', '1111', 'KA','EA' from edi856Item where autoid = '1111'I dont know why I am getting this error i think there is some syntax error: Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'exec'. Msg 156, Level 15, State 1, Line 5
0
320
by: Stef Mientki | last post by:
Terry Reedy wrote: sorry, don't know how this happened, as I always copy/paste ? AFAIK locals() == sys._getframe(0).f_locals AFAIK, again one level up weird, I use it in 2.5 and if I remember well it already worked in 2.4. but exchanging the function with the statement yields exactly the same results Yes ;-) done.
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.