PyTraceToIX


NamePyTraceToIX JSON
Version 1.2.1 PyPI version JSON
download
home_pageNone
SummaryAn expression tracer for debugging lambdas, list comprehensions, method chaining, and expressions
upload_time2024-10-17 22:16:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords debugging tracer debug log logger expression lambda list comprehensions
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Description

![PyPI - Version](https://img.shields.io/pypi/v/pytracetoix)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/a-bentofreire/pytracetoix/.github%2Fworkflows%2Fpython-package.yml)

[PyTraceToIX](https://www.devtoix.com/en/projects/pytracetoix) is an expression tracer designed for debugging Jinja2 templates, Flask web apps, lambdas, list comprehensions, method chaining, and expressions in general.

Code editors often cannot set breakpoints within these kinds of expressions, which requires significant code modifications to debug effectively.

For Jinja2 templates, the debug extension can be used, but it typically dumps the entire context, making it difficult to isolate specific issues. PyTraceToIX solves this by allowing developers to trace and write specific data directly to sys.stdout or a stream without altering the design or making any changes to the web application.

Additionally, PyTraceToIX can capture multiple inputs and their results, displaying them all in a single line, making it easier to view aggregated data and trace the flow of values.

PyTraceToIX offers a straightforward solution to these challenges, simplifying debugging while preserving the integrity of the original codebase.

It was designed to be simple, with easily identifiable functions that can be removed once the bug is found.

PyTraceToIX has 2 major functions:
- `c__` capture the input of an expression input. ex: `c__(x)`
- `d__` display the result of an expression and all the captured inputs. ex: `d__(c__(x) + c__(y))`

And 2 optional functions:
- `init__` initializes display format, output stream and multithreading.
- `t__` defines a name for the current thread.

If you find this project useful, please, read the [Support this Project](https://www.devtoix.com/en/projects/pytracetoix#support-this-project) on how to contribute.

## Features

- No external dependencies.
- Minimalist function names that are simple and short.
- Traces Results along with Inputs.
- Configurable Result and Input naming.
- Output to the `stdout` or a stream.
- Supports multiple levels.
- Capture Input method with customizable `allow` and `name` callbacks.
- Display Result method with customizable `allow`, `before`, and `after` callbacks.
- Result and Inputs can be reformatted and overridden.
- Configurable [formatting](https://www.devtoix.com/en/projects/pytracetoix#formatting) at global level and at function level.
- [Multithreading](https://www.devtoix.com/en/projects/pytracetoix#multithreading) support.

## JavaScript Version

This package is also available in JavaScript for similar debugging purposes. The JavaScript version, called **JsTraceToIX**, allows tracing input and output values during debugging and can be found on [JsTraceToIX](https://www.devtoix.com/en/projects/jstracetoix).

It offers the same `c__` and `d__` tracing functionality for JavaScript, supporting React, Vue, browser and Node.js environments.

## Installation

```bash
pip install pytracetoix
```

## Jinja2 templates Usage

In this example:
- A flask web app uses a Jinja2 template
- It generates a shopping card html table with product, quantity and final price

| Product | Qty | Final Price |
| ------- | --- | ----------- |
| Smartphone | 5 | 2500 |
| Wireless B | 50 | 49960 |
| Smartphone | 20 | 1990 |

- The product name is only the first 11 characters, but we need to know the full name.
- It only shows the final price which is Price * Qty - discount.
- The discount is dependent of the quantity.
- `c__` captures the complete name but doesn't change the design.
- `c__` captures the qty and labels it as Qty.
- `c__` captures the discount value.
- `d__` outputs to sys.stdout all the captured inputs and the final price.

The stdout will display these lines:

```plaintext
i0:`Smartphone 128GB` | qty:`5` | i2:`500` | discount:`0` | _:`2500`
i0:`Wireless Bluetooth Headphones` | qty:`50` | i2:`1000` | discount:`40` | _:`49960`
i0:`Smartphone 64GB Black` | qty:`20` | i2:`100` | discount:`10` | _:`1990`
```

Jinja2 template:

```html
<html lang="en">
<head><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"></head>
<body>
    <div class="container mt-5">
        <h1>Shopping Cart</h1>
        <table class="table table-striped">
            <tr><th>Product</th><th>Qty</th><th>Final Price</th></tr>
            {% for item in purchases %}
            {% set product = products[item['product']] %}
            <tr>
                <td>{{ c__(product['name'])[0:10] }}</td>
                <td>{{ c__(item['qty'], name='qty') }}</td>
                <td>{{ d__(c__(product['price']) * item['qty']
                    - c__(discount(item['qty']), name='discount')) }}</td>
            </tr>
            {% endfor %}
        </table>
    </div>
</body>
</html>
```

app.py:

```python
from flask import Flask, render_template
from pytracetoix import c__, d__

app = Flask(__name__)

app.Jinja2_env.globals['d__'] = d__
app.Jinja2_env.globals['c__'] = c__

DISCOUNTS = {50: 40, 20: 10, 10: 5, 0: 0}
PRODUCTS = {
    'WB50CC': {'name': 'Wireless Bluetooth Headphones', 'price': 1000},
    'PH20XX': {'name': 'Smartphone 128GB', 'price': 500},
    'PH50YY': {'name': 'Smartphone 64GB Black', 'price': 100}
}

PURCHASES = [
    {'product': 'PH20XX', 'qty': 5},
    {'product': 'WB50CC', 'qty': 50},
    {'product': 'PH50YY', 'qty': 20}
]


def discount(qty): return next((k, v) for k, v in DISCOUNTS.items() if k <= qty)[1]


@app.route('/', methods=['GET'])
def index():
    return render_template('index.html', products=PRODUCTS, purchases=PURCHASES, discount=discount)


if __name__ == '__main__':
    app.run(debug=True)
```

If the previous example, we add c__ to the discount function on app.py:

```python
def discount(qty): return c__(next((k, v) for k, v in DISCOUNTS.items() if k <= qty))[1]
```

It will add richer discount information to the output:

```plaintext
i0:`Smartphone 128GB` | qty:`5` | i2:`500` | i3:`(0, 0)` | discount:`0` | _:`2500`
i0:`Wireless Bluetooth Headphones` | qty:`50` | i2:`1000` | i3:`(50, 40)` | discount:`40` | _:`49960`
i0:`Smartphone 64GB Black` | qty:`20` | i2:`100` | i3:`(20, 10)` | discount:`10` | _:`1990`
```

## Detailed Usage and Examples

```python
from pytracetoix import d__, c__

[x, y, w, k, u] = [1, 2, 3, 4 + 4, lambda x:x]
#  expression
z = x + y * w + (k * u(5))

# Display expression with no inputs
z = d__(x + y * w + (k * u(5)))

# Output:
# _:`47`

# Display expression result with inputs
z = d__(c__(x) + y * c__(w) + (k * u(5)))

# Output:
# i0:`1` | i1:`3` | _:`47`

# Display expression result with inputs within an expression
z = d__(c__(x) + y * c__(w) + d__(k * c__(u(5), level=1)))

# Output:
# i0:`5` | _:`40`
# i0:`1` | i1:`3` | _:`47`

# lambda function
f = lambda x, y: x + (y + 1)
f(5, 6)

# Display lambda function result and inputs
f = lambda x, y: d__(c__(x) + c__(y + 1))
f(5, 6)

# Output:
# i0:`5` | i1:`7` | _:`12`

# Display lambda function inputs and result with input and result names
f = lambda x, y: d__(c__(x, name='x') + c__(y + 1, name='y+1'), name='f')
f(5, 6)

# Output:
# x:`5` | y+1:`7` | f:`12`

# list comprehension
l = [5 * y * x for x, y in [(10, 20), (30, 40)]]

# Display list comprehension with input and result names
l = d__([5 * c__(y, name=f"y{y}") * c__(x, name=lambda index, _, __: f'v{index}') for x, y in [(10, 20), (30, 40)]])
# Output:
# y20:`20` | v1:`10` | y40:`40` | v3:`30` | _:`[1000, 6000]`

# Display expression if `input count` is 2
d__(c__(x) + c__(y), allow=lambda data: data['input_count__'] == 2)
# Output:
# i0:`1` | i1:`2` | _:`3`

# Display expression if the first input value is 10.0
d__(c__(x) + c__(y), allow=lambda data: data['i0'] == 10.0)
# No output

# Display expression if the `allow_input_count` is 2, in this case if `x > 10`
d__(c__(x, allow=lambda index, name, value: value > 10) + c__(y),
        allow=lambda data: data['allow_input_count__'] == 2)
# No output

# Display list comprehension if the generated output has the text 10
d__([c__(x) for x in ['10', '20']], before=lambda data: '10' in data['output__'])
# Output:
# i0:`10` | i1:`20` | _:`['10', '20']`

# Display list comprehension and after call `call_after` if it was allowed to display
d__([c__(x) for x in ['10', '20']], allow=lambda data: data['allow_input_count__'] == 2,
        after=lambda data: call_after(data) if data['allow__'] else "")

# Display list comprehension with allow input override
d__([c__(x, allow=lambda index, name, value:value[0]) \
    for x in [('10', '20'), ('30', '40'), ('50', '60')]])
# i0:`10` | i1:`30` | i2:`50` | _:`[('10', '20'), ('30', '40'), ('50', '60')]`

# Display list comprehension with allow result override
d__([c__(x) for x in [('10', '20'), ('30', '40'), ('50', '60')]], \
     allow=lambda data:data['_'][0:2])
# i0:`('10', '20')` | i1:`('30', '40')` | i2:`('50', '60')` | _:`[('10', '20'), ('30', '40')]`

class Chain:
    def __init__(self, data):
        self.data = data

    def map(self, func):
        self.data = list(map(func, self.data))
        return self

    def filter(self, func):
        self.data = list(filter(func, self.data))
        return self


# A class with chain methods
Chain([10, 20, 30, 40, 50]).map(lambda x: x * 2).filter(lambda x: x > 70)

# Display the result and capture the map and filter inputs
d__(Chain([10, 20, 30, 40, 50]).map(lambda x: c__(x * 2)).filter(lambda x: c__(x > 70)).data)

# Output:
# i0:`20` | i1:`40` | i2:`60` | i3:`80` | i4:`100` | i5:`False` | i6:`False` | i7:`False` | i8:`True` | i9:`True` | _:`[80, 100]`

```

## Formatting

The `d__` function can override the default formatting, and it can also be defined at global level.

```python
from pytracetoix import init__

init__(format={
    'result': '{name}:`{value}`',
    'input': '{name}:`{value}`',
    'thread': '{id}: ',
    'sep': ' | ',
    'new_line': True
})
```

Formatting parameters:
- `result`: The result value format will be displayed.
- `input`: The input value format will be displayed.
- `sep`: The separator text between each input and the result.
- `new_line`: If `True` it will add a new line at the end of output.

## Multithreading

To activate the multithreading support:

```python
from pytracetoix import d__, c__, t__, init__

init__(multithreading=True)

## It displays the threadId: i0: `4` | _: `5`
def thread_function():
    d__(c__(4) + 1)

## It displays the something: i0: `4` | _: `5`
def thread_function_with_name():
    t__("something")
    d__(c__(4) + 1)

threads = []
for _ in range(5):
    thread = threading.Thread(target=thread_function)
    threads.append(thread)
threads.append(threading.Thread(target=thread_function_with_name))

for thread in threads:
    thread.start()
for thread in threads:
    thread.join()
```

## Metadata

The `d__` function callbacks `allow`, `before` and `after` will receive a parameter `data` with the allowed inputs plus the following `meta` items:

- `meta__`: list of meta keys including the name key.
- `thread_id__`: thread_id being executed
- `allow_input_count__`: total number of inputs that are allowed.
- `input_count__`: total number of inputs being captured.
- `allow__`: If false it was allowed. Use this for `after` callback.
- `output__`: Text passed to `before` without `new_line`.
- name: name parameter

## Documentation

 [Package Documentation](https://www.devtoix.com/docs/pytracetoix/en/)

## Support this Project

If you find this project useful, consider supporting it:

- Donate:

[![Donate via PayPal](https://www.paypalobjects.com/webstatic/en_US/i/btn/png/blue-rect-paypal-34px.png)](https://www.paypal.com/donate/?business=MCZDHYSK6TCKJ&no_recurring=0&item_name=Support+Open+Source&currency_code=EUR)

[![Buy me a Coffee](https://www.devtoix.com/assets/buymeacoffee-small.png)](https://buymeacoffee.com/abentofreire)

- Visit the project [homepage](https://www.devtoix.com/en/projects/pytracetoix)
- Give the project a ⭐ on [Github](https://github.com/a-bentofreire/pytracetoix)
- Spread the word
- Follow me:
  - [Github](https://github.com/a-bentofreire)
  - [LinkedIn](https://www.linkedin.com/in/abentofreire)
  - [Twitter/X](https://x.com/devtoix)

## License

MIT License

## Copyrights

(c) 2024 [Alexandre Bento Freire](https://www.a-bentofreire.com)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyTraceToIX",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "debugging, tracer, debug, log, logger, expression, lambda, list comprehensions",
    "author": null,
    "author_email": "Alexandre Bento Freire <devtoix@a-bentofreire.com>",
    "download_url": "https://files.pythonhosted.org/packages/7b/80/5810b4ebe0e08402bae5b63bea5911aa3e41924f8496a2e8c28b3ebdb5ce/pytracetoix-1.2.1.tar.gz",
    "platform": null,
    "description": "# Description\n\n![PyPI - Version](https://img.shields.io/pypi/v/pytracetoix)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/a-bentofreire/pytracetoix/.github%2Fworkflows%2Fpython-package.yml)\n\n[PyTraceToIX](https://www.devtoix.com/en/projects/pytracetoix) is an expression tracer designed for debugging Jinja2 templates, Flask web apps, lambdas, list comprehensions, method chaining, and expressions in general.\n\nCode editors often cannot set breakpoints within these kinds of expressions, which requires significant code modifications to debug effectively.\n\nFor Jinja2 templates, the debug extension can be used, but it typically dumps the entire context, making it difficult to isolate specific issues. PyTraceToIX solves this by allowing developers to trace and write specific data directly to sys.stdout or a stream without altering the design or making any changes to the web application.\n\nAdditionally, PyTraceToIX can capture multiple inputs and their results, displaying them all in a single line, making it easier to view aggregated data and trace the flow of values.\n\nPyTraceToIX offers a straightforward solution to these challenges, simplifying debugging while preserving the integrity of the original codebase.\n\nIt was designed to be simple, with easily identifiable functions that can be removed once the bug is found.\n\nPyTraceToIX has 2 major functions:\n- `c__` capture the input of an expression input. ex: `c__(x)`\n- `d__` display the result of an expression and all the captured inputs. ex: `d__(c__(x) + c__(y))`\n\nAnd 2 optional functions:\n- `init__` initializes display format, output stream and multithreading.\n- `t__` defines a name for the current thread.\n\nIf you find this project useful, please, read the [Support this Project](https://www.devtoix.com/en/projects/pytracetoix#support-this-project) on how to contribute.\n\n## Features\n\n- No external dependencies.\n- Minimalist function names that are simple and short.\n- Traces Results along with Inputs.\n- Configurable Result and Input naming.\n- Output to the `stdout` or a stream.\n- Supports multiple levels.\n- Capture Input method with customizable `allow` and `name` callbacks.\n- Display Result method with customizable `allow`, `before`, and `after` callbacks.\n- Result and Inputs can be reformatted and overridden.\n- Configurable [formatting](https://www.devtoix.com/en/projects/pytracetoix#formatting) at global level and at function level.\n- [Multithreading](https://www.devtoix.com/en/projects/pytracetoix#multithreading) support.\n\n## JavaScript Version\n\nThis package is also available in JavaScript for similar debugging purposes. The JavaScript version, called **JsTraceToIX**, allows tracing input and output values during debugging and can be found on [JsTraceToIX](https://www.devtoix.com/en/projects/jstracetoix).\n\nIt offers the same `c__` and `d__` tracing functionality for JavaScript, supporting React, Vue, browser and Node.js environments.\n\n## Installation\n\n```bash\npip install pytracetoix\n```\n\n## Jinja2 templates Usage\n\nIn this example:\n- A flask web app uses a Jinja2 template\n- It generates a shopping card html table with product, quantity and final price\n\n| Product | Qty | Final Price |\n| ------- | --- | ----------- |\n| Smartphone | 5 | 2500 |\n| Wireless B | 50 | 49960 |\n| Smartphone | 20 | 1990 |\n\n- The product name is only the first 11 characters, but we need to know the full name.\n- It only shows the final price which is Price * Qty - discount.\n- The discount is dependent of the quantity.\n- `c__` captures the complete name but doesn't change the design.\n- `c__` captures the qty and labels it as Qty.\n- `c__` captures the discount value.\n- `d__` outputs to sys.stdout all the captured inputs and the final price.\n\nThe stdout will display these lines:\n\n```plaintext\ni0:`Smartphone 128GB` | qty:`5` | i2:`500` | discount:`0` | _:`2500`\ni0:`Wireless Bluetooth Headphones` | qty:`50` | i2:`1000` | discount:`40` | _:`49960`\ni0:`Smartphone 64GB Black` | qty:`20` | i2:`100` | discount:`10` | _:`1990`\n```\n\nJinja2 template:\n\n```html\n<html lang=\"en\">\n<head><link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css\" rel=\"stylesheet\"></head>\n<body>\n    <div class=\"container mt-5\">\n        <h1>Shopping Cart</h1>\n        <table class=\"table table-striped\">\n            <tr><th>Product</th><th>Qty</th><th>Final Price</th></tr>\n            {% for item in purchases %}\n            {% set product = products[item['product']] %}\n            <tr>\n                <td>{{ c__(product['name'])[0:10] }}</td>\n                <td>{{ c__(item['qty'], name='qty') }}</td>\n                <td>{{ d__(c__(product['price']) * item['qty']\n                    - c__(discount(item['qty']), name='discount')) }}</td>\n            </tr>\n            {% endfor %}\n        </table>\n    </div>\n</body>\n</html>\n```\n\napp.py:\n\n```python\nfrom flask import Flask, render_template\nfrom pytracetoix import c__, d__\n\napp = Flask(__name__)\n\napp.Jinja2_env.globals['d__'] = d__\napp.Jinja2_env.globals['c__'] = c__\n\nDISCOUNTS = {50: 40, 20: 10, 10: 5, 0: 0}\nPRODUCTS = {\n    'WB50CC': {'name': 'Wireless Bluetooth Headphones', 'price': 1000},\n    'PH20XX': {'name': 'Smartphone 128GB', 'price': 500},\n    'PH50YY': {'name': 'Smartphone 64GB Black', 'price': 100}\n}\n\nPURCHASES = [\n    {'product': 'PH20XX', 'qty': 5},\n    {'product': 'WB50CC', 'qty': 50},\n    {'product': 'PH50YY', 'qty': 20}\n]\n\n\ndef discount(qty): return next((k, v) for k, v in DISCOUNTS.items() if k <= qty)[1]\n\n\n@app.route('/', methods=['GET'])\ndef index():\n    return render_template('index.html', products=PRODUCTS, purchases=PURCHASES, discount=discount)\n\n\nif __name__ == '__main__':\n    app.run(debug=True)\n```\n\nIf the previous example, we add c__ to the discount function on app.py:\n\n```python\ndef discount(qty): return c__(next((k, v) for k, v in DISCOUNTS.items() if k <= qty))[1]\n```\n\nIt will add richer discount information to the output:\n\n```plaintext\ni0:`Smartphone 128GB` | qty:`5` | i2:`500` | i3:`(0, 0)` | discount:`0` | _:`2500`\ni0:`Wireless Bluetooth Headphones` | qty:`50` | i2:`1000` | i3:`(50, 40)` | discount:`40` | _:`49960`\ni0:`Smartphone 64GB Black` | qty:`20` | i2:`100` | i3:`(20, 10)` | discount:`10` | _:`1990`\n```\n\n## Detailed Usage and Examples\n\n```python\nfrom pytracetoix import d__, c__\n\n[x, y, w, k, u] = [1, 2, 3, 4 + 4, lambda x:x]\n#  expression\nz = x + y * w + (k * u(5))\n\n# Display expression with no inputs\nz = d__(x + y * w + (k * u(5)))\n\n# Output:\n# _:`47`\n\n# Display expression result with inputs\nz = d__(c__(x) + y * c__(w) + (k * u(5)))\n\n# Output:\n# i0:`1` | i1:`3` | _:`47`\n\n# Display expression result with inputs within an expression\nz = d__(c__(x) + y * c__(w) + d__(k * c__(u(5), level=1)))\n\n# Output:\n# i0:`5` | _:`40`\n# i0:`1` | i1:`3` | _:`47`\n\n# lambda function\nf = lambda x, y: x + (y + 1)\nf(5, 6)\n\n# Display lambda function result and inputs\nf = lambda x, y: d__(c__(x) + c__(y + 1))\nf(5, 6)\n\n# Output:\n# i0:`5` | i1:`7` | _:`12`\n\n# Display lambda function inputs and result with input and result names\nf = lambda x, y: d__(c__(x, name='x') + c__(y + 1, name='y+1'), name='f')\nf(5, 6)\n\n# Output:\n# x:`5` | y+1:`7` | f:`12`\n\n# list comprehension\nl = [5 * y * x for x, y in [(10, 20), (30, 40)]]\n\n# Display list comprehension with input and result names\nl = d__([5 * c__(y, name=f\"y{y}\") * c__(x, name=lambda index, _, __: f'v{index}') for x, y in [(10, 20), (30, 40)]])\n# Output:\n# y20:`20` | v1:`10` | y40:`40` | v3:`30` | _:`[1000, 6000]`\n\n# Display expression if `input count` is 2\nd__(c__(x) + c__(y), allow=lambda data: data['input_count__'] == 2)\n# Output:\n# i0:`1` | i1:`2` | _:`3`\n\n# Display expression if the first input value is 10.0\nd__(c__(x) + c__(y), allow=lambda data: data['i0'] == 10.0)\n# No output\n\n# Display expression if the `allow_input_count` is 2, in this case if `x > 10`\nd__(c__(x, allow=lambda index, name, value: value > 10) + c__(y),\n        allow=lambda data: data['allow_input_count__'] == 2)\n# No output\n\n# Display list comprehension if the generated output has the text 10\nd__([c__(x) for x in ['10', '20']], before=lambda data: '10' in data['output__'])\n# Output:\n# i0:`10` | i1:`20` | _:`['10', '20']`\n\n# Display list comprehension and after call `call_after` if it was allowed to display\nd__([c__(x) for x in ['10', '20']], allow=lambda data: data['allow_input_count__'] == 2,\n        after=lambda data: call_after(data) if data['allow__'] else \"\")\n\n# Display list comprehension with allow input override\nd__([c__(x, allow=lambda index, name, value:value[0]) \\\n    for x in [('10', '20'), ('30', '40'), ('50', '60')]])\n# i0:`10` | i1:`30` | i2:`50` | _:`[('10', '20'), ('30', '40'), ('50', '60')]`\n\n# Display list comprehension with allow result override\nd__([c__(x) for x in [('10', '20'), ('30', '40'), ('50', '60')]], \\\n     allow=lambda data:data['_'][0:2])\n# i0:`('10', '20')` | i1:`('30', '40')` | i2:`('50', '60')` | _:`[('10', '20'), ('30', '40')]`\n\nclass Chain:\n    def __init__(self, data):\n        self.data = data\n\n    def map(self, func):\n        self.data = list(map(func, self.data))\n        return self\n\n    def filter(self, func):\n        self.data = list(filter(func, self.data))\n        return self\n\n\n# A class with chain methods\nChain([10, 20, 30, 40, 50]).map(lambda x: x * 2).filter(lambda x: x > 70)\n\n# Display the result and capture the map and filter inputs\nd__(Chain([10, 20, 30, 40, 50]).map(lambda x: c__(x * 2)).filter(lambda x: c__(x > 70)).data)\n\n# Output:\n# i0:`20` | i1:`40` | i2:`60` | i3:`80` | i4:`100` | i5:`False` | i6:`False` | i7:`False` | i8:`True` | i9:`True` | _:`[80, 100]`\n\n```\n\n## Formatting\n\nThe `d__` function can override the default formatting, and it can also be defined at global level.\n\n```python\nfrom pytracetoix import init__\n\ninit__(format={\n    'result': '{name}:`{value}`',\n    'input': '{name}:`{value}`',\n    'thread': '{id}: ',\n    'sep': ' | ',\n    'new_line': True\n})\n```\n\nFormatting parameters:\n- `result`: The result value format will be displayed.\n- `input`: The input value format will be displayed.\n- `sep`: The separator text between each input and the result.\n- `new_line`: If `True` it will add a new line at the end of output.\n\n## Multithreading\n\nTo activate the multithreading support:\n\n```python\nfrom pytracetoix import d__, c__, t__, init__\n\ninit__(multithreading=True)\n\n## It displays the threadId: i0: `4` | _: `5`\ndef thread_function():\n    d__(c__(4) + 1)\n\n## It displays the something: i0: `4` | _: `5`\ndef thread_function_with_name():\n    t__(\"something\")\n    d__(c__(4) + 1)\n\nthreads = []\nfor _ in range(5):\n    thread = threading.Thread(target=thread_function)\n    threads.append(thread)\nthreads.append(threading.Thread(target=thread_function_with_name))\n\nfor thread in threads:\n    thread.start()\nfor thread in threads:\n    thread.join()\n```\n\n## Metadata\n\nThe `d__` function callbacks `allow`, `before` and `after` will receive a parameter `data` with the allowed inputs plus the following `meta` items:\n\n- `meta__`: list of meta keys including the name key.\n- `thread_id__`: thread_id being executed\n- `allow_input_count__`: total number of inputs that are allowed.\n- `input_count__`: total number of inputs being captured.\n- `allow__`: If false it was allowed. Use this for `after` callback.\n- `output__`: Text passed to `before` without `new_line`.\n- name: name parameter\n\n## Documentation\n\n [Package Documentation](https://www.devtoix.com/docs/pytracetoix/en/)\n\n## Support this Project\n\nIf you find this project useful, consider supporting it:\n\n- Donate:\n\n[![Donate via PayPal](https://www.paypalobjects.com/webstatic/en_US/i/btn/png/blue-rect-paypal-34px.png)](https://www.paypal.com/donate/?business=MCZDHYSK6TCKJ&no_recurring=0&item_name=Support+Open+Source&currency_code=EUR)\n\n[![Buy me a Coffee](https://www.devtoix.com/assets/buymeacoffee-small.png)](https://buymeacoffee.com/abentofreire)\n\n- Visit the project [homepage](https://www.devtoix.com/en/projects/pytracetoix)\n- Give the project a \u2b50 on [Github](https://github.com/a-bentofreire/pytracetoix)\n- Spread the word\n- Follow me:\n  - [Github](https://github.com/a-bentofreire)\n  - [LinkedIn](https://www.linkedin.com/in/abentofreire)\n  - [Twitter/X](https://x.com/devtoix)\n\n## License\n\nMIT License\n\n## Copyrights\n\n(c) 2024 [Alexandre Bento Freire](https://www.a-bentofreire.com)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An expression tracer for debugging lambdas, list comprehensions, method chaining, and expressions",
    "version": "1.2.1",
    "project_urls": {
        "Changelog": "https://github.com/a-bentofreire/pytracetoix/blob/HEAD/CHANGELOG.md",
        "Documentation": "https://www.devtoix.com/docs/pytracetoix/en/",
        "Homepage": "https://www.devtoix.com/en/projects/pytracetoix",
        "Issues": "https://github.com/a-bentofreire/pytracetoix/issues",
        "Repository": "https://github.com/a-bentofreire/pytracetoix",
        "Twitter": "https://x.com/devtoix"
    },
    "split_keywords": [
        "debugging",
        " tracer",
        " debug",
        " log",
        " logger",
        " expression",
        " lambda",
        " list comprehensions"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ce667f515164a6b8c1d43ca0fcc02b9920d66052d779349ce968c0f431eb05d",
                "md5": "423211c924255975724dd9a2d3678172",
                "sha256": "85df7b7d69d66e8324315c97e93e4ebaf77d335c3d22a701537a3ce81b70119e"
            },
            "downloads": -1,
            "filename": "PyTraceToIX-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "423211c924255975724dd9a2d3678172",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9932,
            "upload_time": "2024-10-17T22:16:00",
            "upload_time_iso_8601": "2024-10-17T22:16:00.834033Z",
            "url": "https://files.pythonhosted.org/packages/8c/e6/67f515164a6b8c1d43ca0fcc02b9920d66052d779349ce968c0f431eb05d/PyTraceToIX-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b805810b4ebe0e08402bae5b63bea5911aa3e41924f8496a2e8c28b3ebdb5ce",
                "md5": "21b1b5dbf93ce265927b3d603c699ff8",
                "sha256": "5b2c85566ed480de4115a7c096bf048705d3ec239c3cc0924a80c8dfc54276dd"
            },
            "downloads": -1,
            "filename": "pytracetoix-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "21b1b5dbf93ce265927b3d603c699ff8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9760,
            "upload_time": "2024-10-17T22:16:02",
            "upload_time_iso_8601": "2024-10-17T22:16:02.181473Z",
            "url": "https://files.pythonhosted.org/packages/7b/80/5810b4ebe0e08402bae5b63bea5911aa3e41924f8496a2e8c28b3ebdb5ce/pytracetoix-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 22:16:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "a-bentofreire",
    "github_project": "pytracetoix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytracetoix"
}
        
Elapsed time: 0.31879s