To: vim_dev@googlegroups.com
Subject: Patch 7.3.1067
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.1067
Problem: Python: documentation lags behind.
Solution: Python patch 26. (ZyX)
Files: runtime/doc/if_pyth.txt
*** ../vim-7.3.1066/runtime/doc/if_pyth.txt 2013-05-30 13:01:14.000000000 +0200
--- runtime/doc/if_pyth.txt 2013-05-30 13:31:16.000000000 +0200
***************
*** 480,496 ****
vim.VAR_DEF_SCOPE |g:| or |l:| dictionary
vim.VAR_SCOPE Other scope dictionary,
see |internal-variables|
! Methods:
Method Description ~
keys() Returns a list with dictionary keys.
values() Returns a list with dictionary values.
items() Returns a list of 2-tuples with dictionary contents.
! update(iterable)
! update(dictionary)
! update(**kwargs)
Adds keys to dictionary.
Examples: >
! py d = vim.bindeval('{}')
d['a'] = 'b' # Item assignment
print d['a'] # getting item
d.update({'c': 'd'}) # .update(dictionary)
--- 480,515 ----
vim.VAR_DEF_SCOPE |g:| or |l:| dictionary
vim.VAR_SCOPE Other scope dictionary,
see |internal-variables|
! Methods (note: methods do not support keyword arguments):
Method Description ~
keys() Returns a list with dictionary keys.
values() Returns a list with dictionary values.
items() Returns a list of 2-tuples with dictionary contents.
! update(iterable), update(dictionary), update(**kwargs)
Adds keys to dictionary.
+ get(key[, default=None])
+ Obtain key from dictionary, returning the default if it is
+ not present.
+ pop(key[, default])
+ Remove specified key from dictionary and return
+ corresponding value. If key is not found and default is
+ given returns the default, otherwise raises KeyError.
+ popitem(key)
+ Remove specified key from dictionary and return a pair
+ with it and the corresponding value. Returned key is a new
+ object.
+ has_key(key)
+ Check whether dictionary contains specified key, similar
+ to `key in dict`.
+
+ __new__(), __new__(iterable), __new__(dictionary), __new__(update)
+ You can use `vim.Dictionary()` to create new vim
+ dictionaries. `d=vim.Dictionary(arg)` is the same as
+ `d=vim.bindeval('{}');d.update(arg)`. Without arguments
+ constructs empty dictionary.
+
Examples: >
! d = vim.Dictionary(food="bar") # Constructor
d['a'] = 'b' # Item assignment
print d['a'] # getting item
d.update({'c': 'd'}) # .update(dictionary)
***************
*** 501,506 ****
--- 520,526 ----
for key, val in d.items(): # .items()
print isinstance(d, vim.Dictionary) # True
for key in d: # Iteration over keys
+ class Dict(vim.Dictionary): # Subclassing
<
Note: when iterating over keys you should not modify dictionary.
***************
*** 510,517 ****
following methods:
Method Description ~
extend(item) Add items to the list.
Examples: >
! l = vim.bindeval('[]')
l.extend(['abc', 'def']) # .extend() method
print l[1:] # slicing
l[:0] = ['ghi', 'jkl'] # slice assignment
--- 530,543 ----
following methods:
Method Description ~
extend(item) Add items to the list.
+
+ __new__(), __new__(iterable)
+ You can use `vim.List()` to create new vim lists.
+ `l=vim.List(iterable)` is the same as
+ `l=vim.bindeval('[]');l.extend(iterable)`. Without
+ arguments constructs empty list.
Examples: >
! l = vim.List("abc") # Constructor, result: ['a', 'b', 'c']
l.extend(['abc', 'def']) # .extend() method
print l[1:] # slicing
l[:0] = ['ghi', 'jkl'] # slice assignment
***************
*** 519,531 ****
l[0] = 'mno' # assignment
for i in l: # iteration
print isinstance(l, vim.List) # True
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|.
Examples: >
! f = vim.bindeval('function("tr")')
print f('abc', 'a', 'b') # Calls tr('abc', 'a', 'b')
vim.command('''
function DictFun() dict
--- 545,560 ----
l[0] = 'mno' # assignment
for i in l: # iteration
print isinstance(l, vim.List) # True
+ 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))`.
!
Examples: >
! f = vim.Function('tr') # Constructor
print f('abc', 'a', 'b') # Calls tr('abc', 'a', 'b')
vim.command('''
function DictFun() dict
*** ../vim-7.3.1066/src/version.c 2013-05-30 13:28:37.000000000 +0200
--- src/version.c 2013-05-30 13:31:42.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
{ /* Add new patch number below this line */
+ /**/
+ 1067,
/**/
--
How To Keep A Healthy Level Of Insanity:
9. As often as possible, skip rather than walk.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///