Dennis Lee Bieber wrote:
> > But the solutions already proposed seems to work file for my sample
> > program. I will try on my project soon :)
>
> Looking at the documentation for "execfile", I can see /how/ the
> problem occurs -- but can't determine if this can be considered
> "expected".
>
> -=
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
> On 30 Nov 2005 00:58:45 -0800, [EMAIL PROTECTED]
> declaimed the following in comp.lang.python:
>
>> yes I have imported math in the file I want to use it. But the
>> imported module "math" is not visible in function withou
[EMAIL PROTECTED] wrote:
> I think I understand my problem, but first the sample code extracted to
> my project.
>
> Rq : it's an automatic run of unitary test, the names of unitary test
> are parameter of main program "imported" file via the "execfile"
> function (an usage of "import" instead ma
sample and solution posted in another branch of this thread
--
http://mail.python.org/mailman/listinfo/python-list
yes I have imported math in the file I want to use it. But the imported
module "math" is not visible in function without a global instruction.
But the solutions already proposed seems to work file for my sample
program. I will try on my project soon :)
--
http://mail.python.org/mailman/listinfo/
lot's of solutions proposed in the discussion works fine :
file run.py :
def run_ut( test ) :
# to have the problem the execfile MUST be in a function
# execfile( test ) # ERROR
execfile( test, globals() ) # OK
exec "import ut_00" # OK
exec file(test).read() #
I think I understand my problem, but first the sample code extracted to
my project.
Rq : it's an automatic run of unitary test, the names of unitary test
are parameter of main program "imported" file via the "execfile"
function (an usage of "import" instead may be a solution) :
file run.py :
You're right, the problem is around the usage of "execfile".
But I have still difficulties to get a simple sample and have no
enough time to work on it until end of week.
I will post if I resolve my problem or if I can get a simple sample.
--
http://mail.python.org/mailman/listinfo/python-
Duncan Booth wrote:
> That is unlikely to help. The execfile target seems to have been
> TU_05_010.py, but the file which cannot access math is TU_05_tools.py
> accessed by a normal import, so adding some globals to the execfile call
> won't really do anything useful.
>
> Isn't it fun trying to gu
Duncan Booth wrote:
> Isn't it fun trying to guess the problem in the absence of the code?
What other reason could there be to forego the sane approach -- stick
'import math' everywhere it might belong?
Those exec/execfile() peculiarities are so much more interesting ;-)
Peter
--
http://mail.
Peter Otten wrote:
>> Traceback (most recent call last):
>>File "../tu.py", line 21, in run_tu
>> execfile( filename )
>>File "TU_05_010.py", line 8, in ?
>> import TU_05_tools
>>File "./TU_05_tools.py", line 4, in ?
>> f()
>>File "./
[EMAIL PROTECTED] wrote:
> the error message :
>
> EXCEPTION RAISED::
>
> Traceback (most recent call last):
>File "../tu.py", line 21, in run_tu
> execfile( filename )
>File "TU_05_010.py", line 8, in ?
> import TU_05_tools
>File "./TU_05_tools.py"
wrote:
> I have remarq that this problem is raised when I execute code in an
> imported module (during importation)
>
> I think I will be able to isolate it and have a simple sample soon
>
Meanwhile, try adding:
import math
to the top of TU_05_tools.py.
--
http://mail.python.org/mail
the error message :
EXCEPTION RAISED::
Traceback (most recent call last):
File "../tu.py", line 21, in run_tu
execfile( filename )
File "TU_05_010.py", line 8, in ?
import TU_05_tools
File "./TU_05_tools.py", line 4, in ?
f()
File "./TU_
Sounds like something, either in your program, in another lib you
imported, or perhaps some extension you recently installed (and which
automatically starts), overrides 'import' (replaces it with it's own
version) -- and forgets to add the imported modules properly to the
globlals?
Or something, so
[EMAIL PROTECTED] wrote:
> I have a stange side effect in my project :
>
> in my project I need to write "gobal" to use global symbol :
>
> ...
> import math
> ...
> def f() :
>global math # necessary ?? else next line generate an error
> message ?
what error message?
>print mat
I have a stange side effect in my project :
in my project I need to write "gobal" to use global symbol :
...
import math
...
def f() :
global math # necessary ?? else next line generate an error
message ?
print math.pi
(the problem is for all global module symbol)
I have certainl
17 matches
Mail list logo