[Bf-python] __del__ hook

Rettig, Frank AGTHZA-DAE rettifan at schaeffler.com
Thu Aug 27 15:19:44 CEST 2009


Dear list,
I'am working on a import script for blender. The idea is to use the
__del__ hook to complete the import. The following script works fine on
my python interpreter, but if I use it from Blender I get:
 
Exception NameError: "global name 'datetime' is not defined" in <bound
method X.
__del__ of <__main__.X instance at 0x01FAD440>> ignored
 
Any idea why the code doesn't run with blender?
 
Best regards,
Frank
 
 
import datetime
import time
 

class X:
     def __init__(self):
         self._job_begin_time = datetime.datetime.now()
         print "My job has started at %s " % self._job_begin_time
 
     def __del__(self):
         self._job_end_time = datetime.datetime.now()
         print "My job has ended at %s " % self._job_end_time
         print "Job took this much time: %s" % (self._job_end_time -
                                                self._job_begin_time )
 
     def waste_some_time(self):
      pass
 
print "Starting job X"
myX = X()
myX.waste_some_time()
print "Ending job X"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20090827/9bda93ff/attachment.html>


More information about the Bf-python mailing list