[wingide-users] Problem with inclusion of rtn

Max Slimmer max at theslimmers.net
Wed Jun 20 14:02:52 MDT 2007


I am trying to use a routine that maskarades as a module, this code was
gleaned from python cookbook see below.  After the include for this module I
get the error:
C:\Program Files\Wing IDE 2.1\bin\2.5\src\debug\server\dbgutils.py:320:
RuntimeWarning: tp_compare didn't return -1 or -2 for exception

And then and Exception: AttributeError: _const instance has no attribute
'__name__'

Even if it comment out the code to add __name__ to sys.modules it fails.


=============== const.py ==============
""" From Python Cookbook """

class _const:
	class ConstError(TypeError): pass

	def __setattr__(self,name,value):
		if not self.__dict__.has_key('debug') and
self.__dict__.has_key(name):
			raise self.ConstError, "Can't rebind const(%s)"%name
		self.__dict__[name]=value

	def __delattr__(self,name) :
		del self.__dict__[name]

import sys
sys.modules[__name__]=_const()
============  end const.py =======================



More information about the wingide-users mailing list