Laman Utama Tanya Wiki English Artikel Komuniti E-Mel Ringtones Search

Bantuan | Carian | Ahli | Kalendar

Google

Selamat Datang ( Log In | Daftar )

 
Reply to this topicStart new topic
Kepada Pakar2 Python , Please..., nested function with free variables
LINUXnewbie888
post Dec 5 2007, 10:49 AM
Kiriman #1


Ahli
*

Grup: Learning
Kiriman: 23
Penyertaan: 30-October 07
Dari: Kuala Lumpur
Ahli ke- 37,614



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.gif
Go to the top of the page
 
+Quote Post
unexistance
post Dec 5 2007, 12:16 PM
Kiriman #2


Ahli Rajin
*****

Grup: Members
Kiriman: 1,060
Penyertaan: 29-March 06
Dari: 46350
Ahli ke- 15,794



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.gif


--------------------
mint4(ubuntu7(debian(GNU/Linux2.6))) + XP-SP2@compaq_presario_v3010au
vista-home-basic + fc9(GNU/Linux2.6)@dell_inspiron_530s
Go to the top of the page
 
+Quote Post
Paralys3r
post Dec 8 2007, 02:47 PM
Kiriman #3


Ahli
***

Grup: Members
Kiriman: 193
Penyertaan: 10-December 06
Ahli ke- 21,764



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.


--------------------
USE="lawa alim terer-masak anak-dara -mulut-murai" LANGUAGES="all" emerge isteri
Go to the top of the page
 
+Quote Post
LINUXnewbie888
post Dec 14 2007, 12:48 PM
Kiriman #4


Ahli
*

Grup: Learning
Kiriman: 23
Penyertaan: 30-October 07
Dari: Kuala Lumpur
Ahli ke- 37,614



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
Go to the top of the page
 
+Quote Post
Paralys3r
post Dec 16 2007, 03:10 PM
Kiriman #5


Ahli
***

Grup: Members
Kiriman: 193
Penyertaan: 10-December 06
Ahli ke- 21,764



QUOTE(LINUXnewbie888 @ Dec 14 2007, 12:56 PM) [snapback]620411[/snapback]
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.


--------------------
USE="lawa alim terer-masak anak-dara -mulut-murai" LANGUAGES="all" emerge isteri
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 

RSS Lo-Fi Version Time is now: 30th August 2008 - 08:15 AM

© 1998-2008 Khazanah Maya Computer Systems