Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Turn hard-coded variables into dynamic ones without refactoring.

Project description


Turn hard-coded variables into dynamic ones without refactoring.

This module allows you to run a script where you replace hard-coded variable assignments with a list of values. For example, suppose we have some script ( that looks like this:


def add(x, y=2):
    return x + y

print("Adding {} to 2".format(PARAM))

Without changing anything in, you just create some configuration (config.yml) file like the following:

    - line_number: 1
      variable: PARAM
      value: [1, 2, 3]

And then run this:

$ softshell -f config.yml python

[{'configurations': [{'line_number': 1,
                      'value': [1, 2, 3],
                      'variable': 'PARAM'}],
  'path': ''}]
Going through edit 1/3
Configuration is: [('', [(1, 'PARAM', 1)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmp7sr_umua
Going through edit 2/3
Configuration is: [('', [(1, 'PARAM', 2)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpn5y4b48c
Going through edit 3/3
Configuration is: [('', [(1, 'PARAM', 3)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpo4vlz7e3

You will see three separate log files, each showing the result where we set PARAM to 1, 2, 3, respectively:

$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmp7sr_umua
Configuration is: [('', [(1, 'PARAM', 1)])]
Adding 1 to 2
$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpn5y4b48c
Configuration is: [('', [(1, 'PARAM', 2)])]
Adding 2 to 2
$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpo4vlz7e3
Configuration is: [('', [(1, 'PARAM', 3)])]
Adding 3 to 2

More examples can be found in the examples directory


$ pip install softshell

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for softshell, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size softshell-0.1-py3-none-any.whl (7.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size softshell-0.1.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page