Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How about something like this?

class VariableGenerator(object): def __init__(self, prefix): self.__prefix = prefix

@cached_method    
def __getitem__(self, key):
    return SR.var("%s%s"%(self.__prefix,key))

a=VariableGenerator('a')
a[0], a[1], a[2] # all variables

How about something like this?

class VariableGenerator(object):
    def __init__(self, prefix):
        self.__prefix = prefix

prefix
 @cached_method    
 def __getitem__(self, key):
     return SR.var("%s%s"%(self.__prefix,key))
 a=VariableGenerator('a')
a[0], a[1], a[2] # all variables