Re: python scripting
- At 12:01 AM 7/2/2001 -0300, Alex wrote:
>if you noticed, I want to use a global variable from vim in pythonYou need to use 'execute' to get your line to work correctly. The pain is
>scripting, but I can't make it work.
>that was a simple example, what I really pretend is call python functions
>with vim variables as arguments to it.
>but well, the point is the same. how do I get g:foo to expand before passing
>it to python?
having to add quotes around it. For example,
:execute "py print \"" . g:foo . "\""
will do what you want. You can also do
:let g:foo = "\"Hello World\""
to include the quotes in the variable, then do
:execute "py print " . g:foo
to print the same line.
>Another similar question:I would have to look into this one. Perhaps someone else (Benji?) can
>I try to assign the result of a python function to a vim variable and
>there's no way to get that working either..
>like assiging the return of :py round(3.5) to g:foo or @f or whatever i can
>use from vim then
>I know I can get this one done on the python side by using vim.command() but
>it's not what I want either.
help. I imagine it is the same as adding the result of any vim command
into a variable.