Python Functions Confusion
<p><br>
I am learning Python. I have a function <strong>readwrite(filename, list)</strong>. filename is of type string. list is a list containing strings to be wtitten in the file.</p>

<p>I have a simple function call like this:<br></p>

<pre><code>fname = 'hello.txt'
readwrite('xx'+fname, datalist)
</code></pre>

<p>I am facing problem that when i print the filename argument value inside the function definition, i get hello.txt rather than xxHello.txt - a strange thing which i didnt expect<br>when i do same from commadline, for a sample function, it works fine.
I wonder what I am missing over there.</p>

<p>Here s the code:</p>

<pre><code>def readwrite(fileName, list):
    print 'arg file=',filename
    curdir = os.getcwd();
    fullpath = os.path.join(curdir, filename);
    print('full path calculated as: '+fullpath);
    fileExist = os.path.exists(fullpath);
    if(fileExist):
        print 'file exists and opening in \'arw\'mode'
        fiel = open(fileName, 'arw')    # valid only if exists
    else:
        print "file doesnt exist; opening in \'w\'mode"
        fiel = open(fileName, 'w')      # if it doesnt exist, we cant open it for reading as nothing to read.

    for line in list:
        fiel.write('\n'+line)

    print 'position of new pointer = ', fiel.tell() 
</code></pre>

<p>-- main code calling the function:</p>

<pre><code>filename = 'put.txt'
strList = ['hello', 'how', 'are', 'you']
readwrite(('xx'+filename), strList);
</code></pre>

<p>-- second line in fn def <strong><em>print 'arg file=',filename</em></strong> prints <strong>hello.txt</strong> rather than <strong>xxHello.txt</strong> <br>
This is my confusion as why is it behaving starngely or am i doing smthing wrong.</p>
