summaryrefslogtreecommitdiffstats
path: root/runtime/doc/if_pyth.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-04-14 15:56:09 +0200
committerBram Moolenaar <Bram@vim.org>2016-04-14 15:56:09 +0200
commit8110a091bc749d8748a20807a724a3af3ca6d509 (patch)
tree87a81daf5175f9c892e6eca0e36f64a6400a1cb6 /runtime/doc/if_pyth.txt
parent58de0e2dcc1f2d251b74892a06d71a14973f3187 (diff)
patch 7.4.1731v7.4.1731
Problem: Python: turns partial into simple funcref. Solution: Use partials like partials. (Nikolai Pavlov, closes #734)
Diffstat (limited to 'runtime/doc/if_pyth.txt')
-rw-r--r--runtime/doc/if_pyth.txt28
1 files changed, 24 insertions, 4 deletions
diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt
index 4f79c575b3..3d91814b4f 100644
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -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*