Don't understand a probleme of module time not defined when calling a foo func

Ni Va nivaemail at gmail.com
Mon May 30 16:08:55 EDT 2016


Hi Evereybody,

New in python dev, I don't understand why I obtain a problem of time module import as below in my function foo meanwhile this module is visible from the main core code.

Thank you by advance
Best Regards
Niva


# -*- coding: utf-8 -*-
import time
import sys
from timeout import *

# print help('modules')
print "Starting Test at " + time.ctime()

# @timeout(3)
def foo():
	time.sleep(1)
	res = 0
	x = 0.2
	y = 0.3
	i = 03
	# for i in range(1,15):
	# 	time.sleep(i)
	# 	print "%d seconds have passed" % i
		# vim.command( "echo " + "%d seconds have passed" % i

# main
foo()
print "->Ending Test at " + time.ctime()

_____________
Output:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 16, in PyExecReplace
  File "<string>", line 22, in <module>
  File "<string>", line 11, in foo
NameError: global name 'time' is not defined




More information about the Python-list mailing list