Q:

Python 3 - how to retrieve return value from inside a dictionary comprehension for use in another method?

Python newbie learning dictionary comprehensions here. Consider the following example dictionary that has further dictionary as its value (are they called "multidimensional dictionaries"? Just wondering.): 
 maindictionary = {
'key1':{'key11':'value11','key12':'value12'},
'key2':{'key21':'value21','key22':'value22'}, 
'key3':{'key31':'value31','key32':'value32'},
'key4':{'key41':'value41','key42':'value42'}
}

I'd like to traverse through the main dictionary in a function within a dictionary comprehension that yields a result, which could then be utilized within that loop in another function. The algorithm is like follows: 

Loop through the dictionary, and send value for each key to
functionA, unless key is equal to key3 or key4. 
Take result from functionA and pass it to functionB
Go to next iteration.

functionA returns a dictionary as well. functionB just prints out the result. 
I have a vague idea that it would look something similar to the code below, and this is what I have tested so far and it gives syntax errors: 
{result:functionA(v) for (k,v) in maindictionary if (k != 'key3' or k != 'key4')}
   functionB(result)

I could be totally wrong on the syntax here, so if you could point me to a good dictionary comprehension resource (not the official python docs, they are hard to understand for a starter), that would be great!
EDIT: 
The output from functionA would be the creation of two dictionaries, {'key11':'value11'} and {'key21':'value21'} (per each iteration). These would then be fed into functionB, which would output value11 and then value21 (per iteration). 
I want to use the result from functionA, i.e. a dictionary that is fed into functionB, which then retrieves its value. 

A:

A dictionary comprehension is meant to create dictionaries. In your particular case, you're working with a dictionary that already exists. I do not believe you are looking at the right paradigm. I would suggest using something like a generator, and passing each value individually, like this:
def functionA(__dict):
    for k in __dict:
        if k not in ['key3', 'key4']:
            yield __dict[k]

main_dict = {...}
for item in functionA(main_dict):
    functionB(item)

functionA ia a generator, which loops through the dictionary, yielding items for valid keys which is in turn passed to functionB. 

