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:
-
Import the
VariableHandlerclass from thevariable_handlermodule:from sk_variable_handler import VariableHandler
-
Create an instance of the
VariableHandlerclass:variable_handler = VariableHandler()
-
Call the
get_valuesmethod of theVariableHandlerinstance, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sk_regex_maker-1.0.101.tar.gz.
File metadata
- Download URL: sk_regex_maker-1.0.101.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c70f98e3583459638e060c226a2f615599dec4c84def7965405398c93bbef58
|
|
| MD5 |
1ccb9ad604b475456015b9d1cca1ceb5
|
|
| BLAKE2b-256 |
a901bf63717b672b615472053675e88a1ac856187ee9e3fb55a928e475f36212
|
File details
Details for the file sk_regex_maker-1.0.101-py3-none-any.whl.
File metadata
- Download URL: sk_regex_maker-1.0.101-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fa694eb375742e158913b2b4dce552640e67bd9c33a22bdd2d1ad9be9adb6cb
|
|
| MD5 |
61e0bd986a158feb4432feee49c8d5c8
|
|
| BLAKE2b-256 |
611bd1acab2d4c6ba7ee92f49f6c5a19c92a1ae398ec1c095ea447caedb5e2fe
|