Skip to main content

vardict - dict with variables

Project description

Changelog

For the changelog, see www.salabim.org/vardict/changelog .

Introduction

With vardict, it is possible to build up a dictionary based on variable names and their value. For instance,

first_name = "John"
last_name = "Smith"
name = vardict(first_name, last_name)

Now, name will be dict(first_name='John', last_name='Smith').

In the same call, additional keywords can be added:

name = vardict(first_name, last_name, age=21, nationality="FR")

Now, name will be dict(first_name='John', last_name='Smith', age=21, nationality='FR').

This functionality is handy for calling functions with (many) keyword arguments, e.g. with salabim:

for x in range(1001,100):
    for y in range(701, 100):
        text = f'{x}-{y}'
        sim.Animatext(**vardict(x, y, text, angle=45)) # instead of sim.Animatext(**vardict(x=x, y=y, text=text, angle=45))

Note that only variables are allowed, so no literals or expressions.

Usage

Importing can be done with

import vardict

or

from vardict import vardict

Installation

Just install with pip install vardict.

Project details


Download files

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

Source Distribution

vardict-1.0.5.post0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

vardict-1.0.5.post0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file vardict-1.0.5.post0.tar.gz.

File metadata

  • Download URL: vardict-1.0.5.post0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for vardict-1.0.5.post0.tar.gz
Algorithm Hash digest
SHA256 d6a32ed5cf89938726cf2d3e6412eea2de09bf97be51a435d436f691f474547d
MD5 42dd0e69647cfda2eda4346a72b5d910
BLAKE2b-256 1fa05c63c4dddad58bba8f18d0386b1174c39ff0b7bc73ba53026c6ff6382c4f

See more details on using hashes here.

File details

Details for the file vardict-1.0.5.post0-py3-none-any.whl.

File metadata

  • Download URL: vardict-1.0.5.post0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for vardict-1.0.5.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 57c1156aa794aa0315a82931d3a6c1c53eda4d70b5515a23b3dd19e2c5122402
MD5 e22d96541843fceac79d011879fb2874
BLAKE2b-256 c4a79f7948eae1c75aaada0ee1f0daec73b2da847a9731ec8101a71c7cc92af2

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