Skip to main content

vardict - dict with variables

Project description

vardict

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.4.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.4-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file vardict-1.0.4.tar.gz.

File metadata

  • Download URL: vardict-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 5de59f1e79d6cd9aed953df16e2525731edccd335bf93de16de7df56f09ae9d6
MD5 c1d49513d56dfe607d9b4608a8ec1c18
BLAKE2b-256 1032487f1d382b93aaef369a582b314488bae094d5561bc33803c9a310778f48

See more details on using hashes here.

File details

Details for the file vardict-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: vardict-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d34b34a1943dd7231cb620b13d968f9f2d9a70d5c0688551e490be6e36717e80
MD5 25bf639458bed0552319c38ba91b4d93
BLAKE2b-256 2653a1b1b09132fe61fbec17a5e2c5d6b3ae6ac1061b9b7a4f7c4f7c65c4be60

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