Stef Mientki wrote:
Indendation is screwed. Is the above all do_more body?
Which locals does this get you? __init__'s? (locals()?)
Isn't this just the same as globals()?
This is 3.0 exec function syntax. Postings should specify which
interpreter you are running, especially when mucking with
internals.
Since you are hiding it, I presume you mean to be, not not to be.
Either use module level __all__ or name the function _do_more and anyone
will know it is private to the module.
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() # <<<===
>
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_locals = sys._getframe(1 ).f_locals
p_globals = sys._getframe(1 ).f_globals
try :
exec ( code, p_globals, p_locals )
exec ( code, p_globals, p_locals )
interpreter you are running, especially when mucking with
internals.
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.
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 ?
Why does the above syntax error appear ?
Are there other ways to hide the function ?
will know it is private to the module.