Merge objectcontainer (oc)

Hi,

 

I got 2 different oc (objectcontainer) from 2 functions. To display the content (mainmenu) I have to merge these 2 container. 

 

Is there any easy way to merge them into one? Trying to iterate with them didn't work. Any hints?

Greets

Sascha

Could you do something like


oca.items = oca.items.extend(ocb.items)

That will append one on to the other, assuming my syntax is correct that is :slight_smile:


Sent from my HTC One using Tapatalk

Nope, does not work....

AttributeError: 'MediaContainer' object has no attribute 'items'

I would personally probably change up the way you are doing things, I've never had the need to merge multiple object containers for one menu item .. it sounds like you're doing something a bit funky there to be honest ...

It is possible if you do it like this:

def SomeFunction:
	oc = ObjectContainer()
oc.extend(OtherFunction())
oc.extend(YetAnotherFunction())

return oc

def OtherFunction():
oc = ObjectContainer()
oc.add(…)
return oc

def YetAnotherFunction():
oc = ObjectContainer()
oc.add(…)
return oc

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.