All pastes #36793 Raw Edit

python c-ref

public python v1 · immutable
#36793 ·published 2006-01-14 18:09 UTC
rendered paste body
class UniqueById:	__shared_state = dict()		def __init__(self, i):		self.__id = i		if self.__class__.__shared_state.has_key(i):			self.__dict__, count = self.__class__.__shared_state[i]			self.__class__.__shared_state[i][1] = count + 1			return True		else:			self.__class__.__shared_state[i] = [self.__dict__, 1]			return False		def __del__(self):		count = self.__class__.__shared_state[self.__id][1] - 1		print "count of remaining %s : %s" % (self.__class__, count)		if count == 0:			del self.__class__.__shared_state[self.__id]		else:			self.__class__.__shared_state[self.__id][1] = count	def states(self):		return self.__class__.__shared_stateclass Panel(UniqueById):	def __init__(self, window):		if UniqueById.__init__(self, window):			return				# Initialisations diverses, création de l'objet