Loading ...
Sorry, an error occurred while loading the content.

Re: python scripting

Expand Messages
  • Dan Sharp
    ... You need to use execute to get your line to work correctly. The pain is having to add quotes around it. For example, ... will do what you want. You
    Message 1 of 2 , Jul 2, 2001
    • 0 Attachment
      At 12:01 AM 7/2/2001 -0300, Alex wrote:
      >if you noticed, I want to use a global variable from vim in python
      >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?

      You need to use 'execute' to get your line to work correctly. The pain is
      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 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.

      I would have to look into this one. Perhaps someone else (Benji?) can
      help. I imagine it is the same as adding the result of any vim command
      into a variable.

      Dan Sharp
    Your message has been successfully submitted and would be delivered to recipients shortly.