let
Assign variables wherever, whenever you want.
Installation
Install via pip:
$ pip install let
Done.
If you insist on the (slightly) harder way of installing, from source, you know how to do it already and don’t need my help.
I might later upload the source to: https://github.com/TaylorSMarks/let
Quick Start
Once you’ve installed, you can really quickly verified that it works with just this:
>>> from let import let
>>> if let(count = len('Hello World!')):
... print(count)
12
Documentation
In C, Java, and many other languages, it’s possible to assign variables inside of if or while condition statements. This is useful in allowing you to concisely both assign the value, and check whether a condition is met.
This ability doesn’t exist in Python, because of the thought that when people write something like:
if row = db.fetch_results():
...
They may have actually meant:
if row == db.fetch_results():
...
Personally, I have never made this mistake. It seems far more like a theoretical mistake that could plausibly happen than one that actually happens and warrants removing features, as was chosen in Python.
Anyways, the let function in this module gives you something very close to that ability in other languages. A few examples:
if let(name = longInstanceName.longAttributeName):
...
# Yes, db.fetch_results() should just return a generator. No, it doesn't.
while let(results = db.fetch_results()):
...
if let(count = len(nameValuePair)) != 1:
raise Exception('Bad amount: {}'.format(count))
Copyright
This software is Copyright (c) 2016 Taylor Marks <taylor@marksfam.com>.
See the bundled LICENSE file for more information.
Metadata
Release files for let 1.0.1
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 |
|---|---|---|---|---|
| let-1.0.1.tar.gz | 3.8 kB | Without provenance | Details for let-1.0.1.tar.gz |
Release files / let-1.0.1.tar.gz
| Download URL | let-1.0.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9908eb4c4cddd6c58b3ed7346e1b26fb37da95d0071f04615f1d662495c732b
|
|
BLAKE2b-256 checksum How to use checksums |
9c65a89c6733476523c85c17c717d28bfd333e9b00c0cd71019d342e046d5179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for let 1.0.1
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.