Skip to main content

A simple Variable Handling program

Project description

Variable Handler

This is a Python package that provides a VariableHandler class for extracting variable values from a string of variable declarations.

Installation

To use the VariableHandler package, you need to install it first. You can install it using pip:

pip install sk_variable_handler

Usage

To extract variable values from a string of variable declarations, follow these steps:

  1. Import the VariableHandler class from the variable_handler module:

    from sk_variable_handler import VariableHandler
    
  2. Create an instance of the VariableHandler class:

    variable_handler = VariableHandler()
    
  3. Call the get_values method of the VariableHandler instance, passing the string of variable declarations as an argument. It returns a dictionary containing the variable names as keys and their corresponding values as values.

    declarations = "Your variable declarations"
    values = variable_handler.get_values(declarations)
    

Example

Here is an example that demonstrates the usage of the VariableHandler:

from variable_handler import VariableHandler

variable_handler = VariableHandler()

declarations = "$x=1+2;$y=2+1;$var=12+223+(222+2)+sin(90);$var2=$x+$y;$xy=($var2+$x+$y);$yx=$xy+$var2"
expected_result = {'$x': '3.0', '$y': '3.0', '$var': '460.0', '$var2': '6.0', '$xy': '12.0', '$yx': '18.0'}

result = variable_handler.get_values(declarations)
assert result == expected_result

Test Cases

The package includes a set of unit tests to verify the functionality of the VariableHandler class. The tests cover various scenarios and edge cases to ensure the correct extraction of variable values.

To run the tests, execute the script as a standalone Python program:

python <filename>.py

The output will indicate whether all the tests have passed or if there are any failures.

Please note that the tests are implemented using the unittest framework. Each test case is independent and tests a specific aspect of the VariableHandler functionality.

Contributing

Contributions to the VariableHandler package are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new features, please create a pull request or open an issue on the GitHub repository.

License

The VariableHandler package is distributed under the MIT License. See the LICENSE file for more information.

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

sk_variable_handler-1.0.102.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

sk_variable_handler-1.0.102-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file sk_variable_handler-1.0.102.tar.gz.

File metadata

  • Download URL: sk_variable_handler-1.0.102.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for sk_variable_handler-1.0.102.tar.gz
Algorithm Hash digest
SHA256 7015d6c39b5d19d8dd3968feb41ce1a8685bc60f3b5e056b142424d52ecbb406
MD5 cc9383161f3d66f1231068f2d507f41b
BLAKE2b-256 3815bf85647ae31063949a36884a9ef6d18948f1e0e9625b2ebfd97a10f66ef2

See more details on using hashes here.

File details

Details for the file sk_variable_handler-1.0.102-py3-none-any.whl.

File metadata

File hashes

Hashes for sk_variable_handler-1.0.102-py3-none-any.whl
Algorithm Hash digest
SHA256 48ec010df40c914113263ea65c7a1d07e3db3858084993b50cb86fe8272a738d
MD5 08849dc91baf509b3747ea86252af751
BLAKE2b-256 3dffc51dc45b9ac349e984f0f8c6e44e8257db9e8829d3ada2ae68cbec5e020d

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