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

Uploaded Python 3

File details

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

File metadata

  • Download URL: vardict-1.0.5.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.tar.gz
Algorithm Hash digest
SHA256 90e888cb413972b50e0e630113a5c1f48eed2a05e5b77748729de5baab4e9e46
MD5 ed414f29317388bdfa045d83c9c85f7e
BLAKE2b-256 e674296280ee05dc53bff752e14eb83257c7d2f5683fb9f987ed42e046212ab8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vardict-1.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5b31a6bda0cfafd25ca6b904303fd10a178ecc59b9f5e8e6460f1c567f9861c3
MD5 49807be499f7103c79b42fd78549ddfb
BLAKE2b-256 9c610f85ccb9d6426dee96827f30c51e627d6de067d786a77cdbbad5242d75eb

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