# Varhist Python Package Desicription  

## Overview  

`varhist` is a python package that allows the user to easily view a variable's history through their code. This makes debugging easier. Standart debuggers do not have this capability. Once initialized, varhist will quickly and quietly track a variable's historic values and where/when the values were changed.  

## Installation

<br>

Type `pip install varhist` in your command line or terminal

<br>

## IMPORTANT

For the varhist library to work, you have to type this at the start of your python code.
```python
import sys, varhist
sys.settrace(varhist.trace)
```
This is equivalent to initializing the module. Without this, the module will not function.
You also must put your code in a main function. This is easily done by highlighting all of your code (potentially omitting imports and functions/classes), pressing tab, and then adding a line saying
```python
def main():
```
to the top

E.g.

```python
import sys, varhist
sys.settrace(varhist.trace)
print("Hello World")
```
to

<br>

```python
import sys, varhist
sys.settrace(varhist.trace.)
def main():
    print("Hello World") # Inside a function now!
```

## Examples  

### Basic Usage

<br>

To start tracking a variable, use the .track method. This takes as many arguments as you want and will start tracking all of those variables.
Note: If the variable is created later on in the code (after calling this function), the package will start tracking the variable when it is created. If the variable was created before this was called, only the changed after will be tracked.
When you want to access the history, you can use the varhist.history() function. This neatly prints out the history of all the variable put in as arguments. 
To directly see the history to do something with it, you can use the varhist.HIST variable. This is a dictionary, so to access the history of a variable `c`, use `varhist.HIST['c']`. You will get a list of lists. The first element in every sub-list is the value that the variable was the changed 1. The second is the line number and the third is the function name.

Example

```python
import sys, varhist

def main():
    varhist.track('x', 'y')
    d = 4 # This is ignored

    x = 4
    y = 4
    for i in range(2):
        y = x+1
        x = y+1

    

varhist.history('x', 'y')

