Jump to content
Sign in to follow this  
LINUXnewbie888

Kepada Pakar2 Python , Please...

Recommended Posts

Hmm..

Hi guys. I am new to python, i never done any program in python ( as I was a programmer in .Net) , however I need to recompile python source codes as we are migrating form python 1.5 to 2.4.

I found this error --> SyntaxError: unqualified exec is not allowed in function '_sourceRules' it contains a nested function with free variables

ape ke benda nyer nih ??

Tak paham eden..

please .. senior2... tolong bagi tunjuk ajar kat budak baru/hingusan nih

Thanks .........

:unsure:

Share this post


Link to post
Share on other sites

lagi senang kalau ko post relevant source code kat sini..

anyway, a quick google shows that it has something to do with lambda functions in python, which unfortunately i'm not that familiar :blush:

Share this post


Link to post
Share on other sites

berikan kod awak then orang bleh tunjuk aper yg tak betul.. tapi generally message tu tunjukkan ader yg tak kena dengan kod yang awak "exec" tu.. try something like "exec <expr> in globals()", di mana <expr> tu aper2 la yg awak nak exec.

Share this post


Link to post
Share on other sites

Error nya ialah :

File "DCAMgr.py", line 140, in ?

import DCARulesEngine

File "/home/r32813/genesis/Product/DCAMgr/DCARulesEngine.py", line 166

exec('attr=' + module + '.__dict__')

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

-- This is the file :

exec('attr=' + module + '.__dict__')

methods = filter( lambda f, a=attr : type(a[f])==types.FunctionType and f[0] != '_' , attr.keys() )

for k in methods:

if k not in self.pythonProcsDict['stdlib'].keys():

if k not in self.pythonProcsDict['customlib'].keys():

self.pythonProcsDict['customlib'][k] = module

Share this post


Link to post
Share on other sites

Error nya ialah :

File "DCAMgr.py", line 140, in ?

import DCARulesEngine

File "/home/r32813/genesis/Product/DCAMgr/DCARulesEngine.py", line 166

exec('attr=' + module + '.__dict__')

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

-- This is the file :

exec('attr=' + module + '.__dict__')

methods = filter( lambda f, a=attr : type(a[f])==types.FunctionType and f[0] != '_' , attr.keys() )

for k in methods:

if k not in self.pythonProcsDict['stdlib'].keys():

if k not in self.pythonProcsDict['customlib'].keys():

self.pythonProcsDict['customlib'][k] = module

apa yg awak perlu buat adalah qualify penggunaan exec, i.e dengan "exec 'attr=' + module + '.__dict__' in .." (tengok exec statement nyer reference) atau gantikan nested function yang ader free variable (ni termasuklah anonymous function yang awak define guna lambda). free variable means variable yg awak refer dalam suatu code block, tapi ia tak ditakrifkan dalam code block tersebut.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...