The Whatever Object
An easy way to make lambdas by partial application of python operators.
Inspired by Perl 6 one, see http://perlcabal.org/syn/S02.html#The_Whatever_Object
Usage
from whatever import _, that
# get a list of guys names
names = map(_.name, guys)
names = map(that.name, guys)
odd = map(_ * 2 + 1, range(10))
squares = map(_ ** 2, range(100))
small_squares = filter(_ < 100, squares)
best = max(tries, key=_.score)
sort(guys, key=-that.height)
factorial = lambda n: reduce(_ * _, range(2, n+1))
NOTE: chained comparisons cannot be implemented since there is no boolean overloading in python.
CAVEATS
In some special cases whatever can cause confusion:
_.attr # this makes callable
obj._ # this fetches '_' attribute of obj
_[key] # this works too
d[_] # KeyError, most probably
_._ # short for attrgetter('_')
_[_] # short for lambda d, k: d[k]
if _ == 'Any value':
# You will get here, definitely
# `_ == something` produces callable, which is true
[1, 2, _ * 2, None].index('hi') # => 2, since bool(_ * 2 == 'hi') is True
Also, whatever sometimes fails on late binding:
(_ * 2)('2') # -> NotImplemented
Metadata
Release files for whatever 0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| whatever-0.7.tar.gz | 6.9 kB | Without provenance | Details for whatever-0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| whatever-0.7-py3-none-any.whl | Python 3 | none | any | Details for whatever-0.7-py3-none-any.whl |
Total release size: 12.2 kB
Release files / whatever-0.7.tar.gz
| Download URL | whatever-0.7.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82d9ab46297c41e2fd4947684f666d4f06c632edd458caf4468417da51c84581
|
|
BLAKE2b-256 checksum How to use checksums |
13d8e640240bc42f78846b691b16d66591e4fde0c3db7a3dd1085cd82b3130a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / whatever-0.7-py3-none-any.whl
| Download URL | whatever-0.7-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a862efbb11a88e9b162e88a59a5eb8b1e656df6c39c6e818f7902bf1d27d728
|
|
BLAKE2b-256 checksum How to use checksums |
752b3ae9940b7e3a368160ba183aa97d0493b803da3f73dd46bb9808be0314eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for whatever 0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.