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
VariableHandler
class from thevariable_handler
module:from sk_variable_handler import VariableHandler
-
Create an instance of the
VariableHandler
class:variable_handler = VariableHandler()
-
Call the
get_values
method of theVariableHandler
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
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
Hashes for sk_variable_handler-1.0.101.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 730e5949f869a4291fe489f9e467fe91a77f36552450214c79c516ed381da5b1 |
|
MD5 | e7288a5adab7f47048d7288133109526 |
|
BLAKE2b-256 | 956743494b067e26731b3f2066bd32468166af5a26239b933245a87eaea9e7b5 |
Hashes for sk_variable_handler-1.0.101-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdccaefcec9aab2c721b88bac539b1668044037680c98205ccee0d22e5437709 |
|
MD5 | 8e1f5c80d0afabac48fa68b4630aa64f |
|
BLAKE2b-256 | e7927613e084db01bb1307e9dbccd3ae9a0f07c9dff4df1ef90828ec262fdd26 |