# How to use the argument of a vimscript function in an inner python function?

I have the following vimscript: it contains a vimscript function which executes a python code thanks to python << EOF:

function! Test(myArgument)
python << EOF
def test(myArgument):
print "My argument " + myArgument

test("foo")
EOF
endfunction


How can I use the argument of the vimscript function a:myArgument and pass it as argument to my python function (instead of foo)?

You can use the vim package inside python, you should be able to gain access to vim:

function! Test(myArgument)
python << EOF
import vim

def test(myArgument):
print "My argument " + myArgument

test(vim.eval('a:myArgument'))
EOF
endfunction


You can read about the python integration at :h python and about this particular feature at :h python-eval.