Define a dictionary name within a function
<p>I am writing a function that will take a parameter and, among other things, make a dictionary. I would like the dictionary's name to be based off the name of the input file. Say ht input file is <code>input.xml</code> , i would like the name of the dictionary to be <code>input</code>. Ideally I would use something like this:</p>

<pre><code>def function(input):
    for x in y: list(get value)
    input[:4][key] = [value]
</code></pre>

<p>I am wondering if you know a better way to do this but what i am using now is an extra name in the function:</p>

<pre><code>def function(input, dictname):
    for x in y: list(get value)
    dictname[key] = [value]
</code></pre>

<p>right now I am simply adding a second name to my function but am wondering if there is a way to do this to require fewer inputs.</p>

<hr>

<p>Edit</p>

<hr>

<p>I am including a longer version of the function I am using so you guys can get the context.  This uses a BioPython module to iterate through an XML file of hits. I am using [temp] to hold the hits for each query and then making a dictionary of for each set of query/hits. I would like this dictionary to be named the same as my input file.</p>

<pre><code>from Bio.Blast import NCBIXML

def make_blast_dictionary(blastxml, maxhits, blastdict):
    temp=[]
    for record in NCBIXML.parse(open(blastxml):    
        for number, align in enumerate(record.alignments):
            if number == int(maxhits): break
            temp.append(str(align.title).split("|")[1])
    blastdict[str(record.query_id)] = [temp]
</code></pre>
