Home | Trees | Indices | Help |
|
---|
|
1 from ..utility.Singleton import Singleton 2 3 # Create a unique variable name for the prolog code generation. 4 5 21 22 try: 23 unique_variable_generator 24 except: 25 unique_variable_generator = unique_variables() 26 27 # 28 # Python has generators, so no need for this crap 29 # 30 31 # class VariableGenerator(Singleton): 32 # # @AttributeType int 33 # # The value of the last string that has been generated. 34 # ___lastString = -1 35 # 36 # def __init__(self): 37 # """Create a new variable generator""" 38 # pass 39 # 40 # # @ReturnType string 41 # # get the next variable name. 42 # def getNext(self): 43 # self.___lastString = self.___lastString + 1 44 # return self.__generate() 45 # 46 # # Reset the generator. After the reset variable names are no longer unique! 47 # def reset(self): 48 # self.___lastString = -1 49 # 50 # # Helper for generating the unique string. 51 # def __generate(self): 52 # c = range(ord('A'), ord('Z') + 1) 53 # s = "" 54 # n = self.___lastString 55 # 56 # while n > 25: 57 # s = chr(c[n % 26]) + s 58 # n = n / 26 59 # 60 # s = chr(c[n]) + s 61 # return s 62
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Feb 6 18:36:11 2008 | http://epydoc.sourceforge.net |