Hello again,

So after looking at the problem with fresh eyes, I have come across the 
getattr and setattr functions within python. 

I think I may have cracked it, some initial tests show positive results.

I used getattr(config, configVar).append(object) which seems to have worked 
really well opposed to using setattr(config, configVar, object) which 
seemed to give the equivalent of config.configVar = object rather than 
appending.

As far as general project setup goes however is it advised to using 
config/project wide variables?

Cheers,

Ben

On Wednesday, 25 March 2015 09:45:19 UTC+1, Benjam901 wrote:
>
> Hello all,
>
> I am currently trying to append to a config file global list and have the 
> need to do so using another variable. My problem is as such:
>
> I am iterating through my objects I am placing in my treeview and and 
> checking them against an XML file that has as the tag the string I need to 
> check for and as the attributes the name of the list I need to append to. I 
> need to be able to access the config."list name" using a variable.
>
> For example rather than using config.modelGraphics.append(object) I would 
> be using config."variable_name".append(object)
>
> Is this possible or do I have to use some sort of getter/setter function 
> rather than trying to directly access my variable?
>
> My code is listed below.
>
> Cheers,
>
> Ben
>
>       def checkAssetDefinition(self, object, fileType):
>               object = str(object)
>               for attr in self.xmlAssetDefsList:
>                       if object.startswith(attr):
>                               innerDict = self.xmlAssetDefsList.get(attr)
>                               for myType in innerDict:
>                                       if myType == fileType:
>                                               configVar = 
> innerDict.get(myType)
>                                               config.configVar.append(myType) 
> ???
>                                               # Need to get the config 
> variable from the config list variable
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/497423a5-e64e-4ee0-b5a8-ff367448c6db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to