patch 7.4.1731
Problem: Python: turns partial into simple funcref. Solution: Use partials like partials. (Nikolai Pavlov, closes #734)
This commit is contained in:
@ -653,10 +653,25 @@ vim.List object *python-List*
|
||||
class List(vim.List): # Subclassing
|
||||
|
||||
vim.Function object *python-Function*
|
||||
Function-like object, acting like vim |Funcref| object. Supports `.name`
|
||||
attribute and is callable. Accepts special keyword argument `self`, see
|
||||
|Dictionary-function|. You can also use `vim.Function(name)` constructor,
|
||||
it is the same as `vim.bindeval('function(%s)'%json.dumps(name))`.
|
||||
Function-like object, acting like vim |Funcref| object. Accepts special
|
||||
keyword argument `self`, see |Dictionary-function|. You can also use
|
||||
`vim.Function(name)` constructor, it is the same as
|
||||
`vim.bindeval('function(%s)'%json.dumps(name))`.
|
||||
|
||||
Attributes (read-only):
|
||||
Attribute Description ~
|
||||
name Function name.
|
||||
args `None` or a |python-List| object with arguments. Note that
|
||||
this is a copy of the arguments list, constructed each time
|
||||
you request this attribute. Modifications made to the list
|
||||
will be ignored (but not to the containers inside argument
|
||||
list: this is like |copy()| and not |deepcopy()|).
|
||||
self `None` or a |python-Dictionary| object with self
|
||||
dictionary. Note that explicit `self` keyword used when
|
||||
calling resulting object overrides this attribute.
|
||||
|
||||
Constructor additionally accepts `args` and `self` keywords. If any of
|
||||
them is given then it constructs a partial, see |function()|.
|
||||
|
||||
Examples: >
|
||||
f = vim.Function('tr') # Constructor
|
||||
@ -670,6 +685,11 @@ vim.Function object *python-Function*
|
||||
print f(self={}) # Like call('DictFun', [], {})
|
||||
print isinstance(f, vim.Function) # True
|
||||
|
||||
p = vim.Function('DictFun', self={})
|
||||
print f()
|
||||
p = vim.Function('tr', args=['abc', 'a'])
|
||||
print f('b')
|
||||
|
||||
==============================================================================
|
||||
8. pyeval() and py3eval() Vim functions *python-pyeval*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user