Indexing with keyword arguments
Project description
PEP 472 -- Support for indexing with keyword arguments
This package provides experimental support for indexing with keyword argments, as proposed in https://www.python.org/dev/peps/pep-0472/
We can write
fn(1, 2, a=3, b=4)
and some users wish to be able to write
d[1, 2, a=3, b=4]
particularly for use in data science and annotations.
The module provide a helper function
from kwkeys import o
such that
d[o(1, 2, a=3, b=4)]
works as well as can be reasonably expected, or so the author thinks.
In module kwkey/example_jfine.py there's an implementation of a class PointMap. It is a subclass of dict which supports namedtuple style access to keys.
My approach uses a helper class K for implementing these experiments. Some wish for the syntax of Python to be extended, to allow keyword arguments in the d[...] syntax.
If the syntax is extended, I believe a helper class such as K would be a good idea. Steven D'Aprano believe that K is irrelevant, except for experimentation.
This package, once refined and production ready, could be used to allow the the style of the new syntax to be used with current Python, via
d[o(1, 2, a=3, b=4)]
instead of
d[1, 2, a=3, b=4]
For a recent discussion of PEP 472, see https://mail.python.org/archives/list/python-ideas@python.org/thread/6OGAFDWCXT5QVV23OZWKBY4TXGZBVYZS/#NYXVHO233EUIAND7WC5SRFXYWC74KSLL
To test installation, do
$ python3 -m kwkey.test
kwkey.jfine TestResults(failed=0, attempted=0)
kwkey.example_jfine TestResults(failed=0, attempted=7)
kwkey.tools TestResults(failed=0, attempted=0)
kwkey.test TestResults(failed=0, attempted=0)
kwkey.test_K TestResults(failed=0, attempted=8)
kwkey.sdaprano TestResults(failed=0, attempted=0)
and check for no failures. (The number of tests will change over time.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kwkey-0.0.1.tar.gz
.
File metadata
- Download URL: kwkey-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
da5f9f3160e02f5d52fec717e0038eeb3cf4544f4e1dd15ac87384628a52cc3e
|
|
MD5 |
00001d0099de3126c284b9a70196c05d
|
|
BLAKE2b-256 |
9f73f43f3d3b30bb6c8f8f8f2b25b4339d6ba01ab0216037f1181fa825244af7
|
File details
Details for the file kwkey-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: kwkey-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
2221a3c72d0d0cf00aa9486d45276c3869ea2cca3257d70a917d86deb57a814b
|
|
MD5 |
04ed88dc11720ecc337e2aaaf20a2736
|
|
BLAKE2b-256 |
c9ab30619c2c3facfbd7dba4cd1ba6c5a4bb07cc0007ecbb6a945dd1157f3738
|