[Tutor] importing
Robert Johansson
robert.johansson at math.umu.se
Tue Dec 22 22:14:54 CET 2009
Hi all, suppose I need to import a module inside a class and that I need to
use it in to different methods. Is this is the way to do it?
class test():
import time
def method1(self):
print 'method 1: ', time.clock()
def method2(self):
print 'method 2: ', time.clock()
If I only need the module in one method should I then place it inside that
method or keep it outside?
class test():
def method1(self):
import time
print 'method 1: ', time.clock()
def method2(self):
print 'method 2: '
thanks, Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091222/0b70d69c/attachment.htm>
More information about the Tutor
mailing list