Skip to main content

Assign variables wherever, whenever you want.

Project description

let3

Assign variables wherever, whenever you want.

Overview

let3 is a strict fork of Taylor Marks’s let package with a fix allowing to work with Python3 or higher and with a little code reformatting and minor improvements.

PyPI record.

Documentation.

Overview below is a copy from the original let website (with only the necessary changes regarding let3).

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(f"Bad amount: {count}")

Installation

Prerequisites:

To install run:

python -m pip install --upgrade let3

Development

Prerequisites:

  • Development is strictly based on nox. To install it run:

    python -m pip install --upgrade nox

Visit Development page.

Installation from sources:

clone the sources:

git clone https://github.com/karpierz/let3 let3

and run:

python -m pip install ./let3

or on development mode:

python -m pip install --editable ./let3

License

Copyright (c) 2016-2026 Adam Karpierz
Copyright (c) 2016 Taylor Marks
Licensed under the MIT License
Please refer to the accompanying LICENSE file.

Authors

Sponsoring

If you would like to sponsor the development of this project, your contribution is greatly appreciated.
As I am now retired, any support helps me dedicate more time to maintaining and improving this work.

Donate

Project details


Release history Release notifications | RSS feed

This version

2.4.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

let3-2.4.3.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

let3-2.4.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file let3-2.4.3.tar.gz.

File metadata

  • Download URL: let3-2.4.3.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for let3-2.4.3.tar.gz
Algorithm Hash digest
SHA256 1c3b7a5fb80812b6b6cd6be934582e178c9fe2dcce1ed16f27c941cfc7800ff7
MD5 d47c1ded46fa1adc116a4702130c8488
BLAKE2b-256 f1eacd5746099c4ba52c6a027be8cbfd2e10d97610709ceb65820d5a72a4be1f

See more details on using hashes here.

File details

Details for the file let3-2.4.3-py3-none-any.whl.

File metadata

  • Download URL: let3-2.4.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for let3-2.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 841d04e9f0e8b704245e74f8898093e948aab3fbf8e02ce53c47d66d86d31b0c
MD5 7671cd431d381db332e0f23eca52f53d
BLAKE2b-256 7a09ea32cd2bd4e46b458b44b02cbdfe52789c1b7955088ace1516609a63f97b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page