Curious why you have a class that is using globals like that? Globals
are a messy way to pass values into your class.
Why not just let the class store references to what it is creating?
And then use it to get values back.
class Myclass(object):
Items = {}
def createOne(name, val):
Items[name] = val
Are you trying to create a methos that dyna,ically creates attribues
on your class? Why do you want object names to be attributes? Why not
use a dict as a class attribute.
Could you maybe explain what you want this class to do?
On Aug 19, 3:29 pm, PixelMuncher <[email protected]> wrote:
> Chris:
> That's what I was looking for. The next best solution I received was
> using a dictionary inside the class.
> Thanks much.
> # Use setattr to 'create an attribute inside the Class:
> prefix = 'pre_'
> myColors = ['red','yellow','blue']
> class makeVars(object):
> global red
> red = ''
> def create (self, prefix,myVars):
> for string in myVars:
> setattr(makeVars, string, cmds.group(em = 1, n= '%s_%s' %
> (prefix, string)))
> print 'string: %s. Value: %s' %
> (string,getattr(makeVars,string))
> cmds.select(makeVars.red)
> makeVars().create(prefix,myColors)
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe