var-print


Namevar-print JSON
Version 0.0.9 PyPI version JSON
download
home_pageNone
SummaryNicer printing with var_print: Colours and structure allow quick reading of the output, at the same time the name of the variable is displayed.
upload_time2024-05-12 12:26:09
maintainerNone
docs_urlNone
authorAndré Herber
requires_pythonNone
licenseNone
keywords python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# var_print

[GitHub](https://github.com/ICreedenI/var_print) | [PyPI](https://pypi.org/project/var-print/)  



This package was inspired by [icecream](https://github.com/gruns/icecream). Please check it out if you consider installing any variable printer. Similar to icecream you can print not only the variable value but the name as well.  

At the same time the content gets nicely formated resulting in readable dictionaries, lists, tuples, sets, frozensets and generators even if they are nested.  

As a neat finish the output is colored. By default the variable name is white, the value blue, dictionary keys are green, dictionary values are yellow and the syntax is white.  

But you are not bound to this color scheme. There are a few stored in the color_schemes property of varpFore which you can choose from. But that's not the limit. You can choose the rgb code to customize the display.



## Content

- Installation

- Usage

  - Normal usage

  - Options

- Planned



## Installation

`pip install var-print`



## Usage

### Normal usage

It's pretty simple nevertheless there are many options to dig into.

To use it as is simply call varp after importing it.

```python

from var_print import varp

x = 1

varp(x)

# prints: 

# x = 1

```

When calling varp with multiple arguments / variables they are handled one by one.

```python

a, b = 1, 2

varp(a, b)

# prints:

# a = 1

# b = 2

```

Calling them as a tuple (or list) will make a single line out of it.

```python

varp((a, b))

# prints:

# (a, b) = (1, 2)

```

For demonstration purposes, the following functions are included.

```python

varp.show_current_color_preset()

```

Result:  

![To view an image of the result visit GitHub](images/current_color_preset.png)



```python

varp.show_a_nested_dictionary()

```

Result:  

![To view an image of the result visit GitHub](images/nested_dict.png)



```python

varp.show_formating_of_different_types()

```

Result:  

![To view an image of the result visit GitHub](images/different_types.png)





### Options:

- `varp.colored`  

  Set it to False to print without colors.

- `varp.deactivated`  

  Set it to True to deactivate the output or call `varp.deactivate()` / `varp.activate()`  

- `varp.name_value_sep`  

  Seperator for the variable name and the value. Default value is `' = '`.

- `varp.comma`  

  Seperator for the values of iterables. Default value is `', '`.

- `varp.prefix`  

  Prefix for all prints with varp. Default is `''` (no prefix). 

- `varp.iter_items_per_line`  

  When printing a list or other iterables, you may want to limit how many items can be printed on a line to improve readability. *Default value is 10.* Note that for better readability I chose to insert a line break after every closing dictionary, list, tuple, set, frozenset and generator.

- `varp.dict_items_per_line`  

  Should be like `varp.iter_items_per_line` but I format the lenght of every key to the max lenght of all keys to achieve better readability when printing only one item per line so you need to set `varp.dict_alignment` to `'none'` to deactivate alignment.

- `varp.dict_alignment`  

  Default value is `'left'` but you might want to choose `'right'` or `'none'`. Keys and values are aligned as wished. If `'none'` is chosen there is no alignment. Also possible is a tuple containing to values, each beeing one of the mentioned three, to set the alignment for the key and the value seperately. 

- `varp.list_alignment`  

  Same as `varp.dict_alignment` but for lists, tuples, sets, frozensets and generators and only with one value of `'left'`, `'right'` or `'none'`

- `varp.color_preset(preset)`  

  Getting different colors is as easy as calling `varp.color_preset` with the preset of your choice. There are a bunch of presets saved in `varpFore.all_presets`. Since every preset has the key 'name' you can choose a preset by name with `varpFore.get_preset_by_name(name)`. 

- `varp.show_all_color_presets`  

  Calling this function will print out every color_preset saved in `varpFore.all_presets`.

- `varp.show_current_color_preset`  

  You guessed it this shows you your current color preset.  

- `varp.save_current_color_preset`  

  Don't like the available color presets? Save your own!

- `varp.varname_rgb`  

  r, g, b code for the variable name

- `varp.name_value_sep_rgb`  

  r, g, b code for the seperator of the variable naem and the value

- `varp.value_rgb`  

  r, g, b code for the value

- `varp.comma_rgb`  

  r, g, b code for the comma (or any varp.comma string)

- `varp.prefix_rgb`  

  r, g, b code for the prefix

- `varp.dict_keys_rgb`  

  r, g, b code for the dictionary keys

- `varp.dict_vals_rgb`  

  r, g, b code for dictionary values





## Planned

I plan on adding different colors for different nesting levels and more formatting cases for numpy and what not.  

There are problems fitting the output to the terminal but as soon as I have that figured out I will add it.




            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "var-print",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python",
    "author": "Andr\u00e9 Herber",
    "author_email": "andre.herber.programming@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/12/00d35f1ef302deba67dc6685c31a549f33c451a6d26cf3dbecc333dc8ccf/var_print-0.0.9.tar.gz",
    "platform": null,
    "description": "\n# var_print\n\n[GitHub](https://github.com/ICreedenI/var_print) | [PyPI](https://pypi.org/project/var-print/)  \n\n\n\nThis package was inspired by [icecream](https://github.com/gruns/icecream). Please check it out if you consider installing any variable printer. Similar to icecream you can print not only the variable value but the name as well.  \n\nAt the same time the content gets nicely formated resulting in readable dictionaries, lists, tuples, sets, frozensets and generators even if they are nested.  \n\nAs a neat finish the output is colored. By default the variable name is white, the value blue, dictionary keys are green, dictionary values are yellow and the syntax is white.  \n\nBut you are not bound to this color scheme. There are a few stored in the color_schemes property of varpFore which you can choose from. But that's not the limit. You can choose the rgb code to customize the display.\n\n\n\n## Content\n\n- Installation\n\n- Usage\n\n  - Normal usage\n\n  - Options\n\n- Planned\n\n\n\n## Installation\n\n`pip install var-print`\n\n\n\n## Usage\n\n### Normal usage\n\nIt's pretty simple nevertheless there are many options to dig into.\n\nTo use it as is simply call varp after importing it.\n\n```python\n\nfrom var_print import varp\n\nx = 1\n\nvarp(x)\n\n# prints: \n\n# x = 1\n\n```\n\nWhen calling varp with multiple arguments / variables they are handled one by one.\n\n```python\n\na, b = 1, 2\n\nvarp(a, b)\n\n# prints:\n\n# a = 1\n\n# b = 2\n\n```\n\nCalling them as a tuple (or list) will make a single line out of it.\n\n```python\n\nvarp((a, b))\n\n# prints:\n\n# (a, b) = (1, 2)\n\n```\n\nFor demonstration purposes, the following functions are included.\n\n```python\n\nvarp.show_current_color_preset()\n\n```\n\nResult:  \n\n![To view an image of the result visit GitHub](images/current_color_preset.png)\n\n\n\n```python\n\nvarp.show_a_nested_dictionary()\n\n```\n\nResult:  \n\n![To view an image of the result visit GitHub](images/nested_dict.png)\n\n\n\n```python\n\nvarp.show_formating_of_different_types()\n\n```\n\nResult:  \n\n![To view an image of the result visit GitHub](images/different_types.png)\n\n\n\n\n\n### Options:\n\n- `varp.colored`  \n\n  Set it to False to print without colors.\n\n- `varp.deactivated`  \n\n  Set it to True to deactivate the output or call `varp.deactivate()` / `varp.activate()`  \n\n- `varp.name_value_sep`  \n\n  Seperator for the variable name and the value. Default value is `' = '`.\n\n- `varp.comma`  \n\n  Seperator for the values of iterables. Default value is `', '`.\n\n- `varp.prefix`  \n\n  Prefix for all prints with varp. Default is `''` (no prefix). \n\n- `varp.iter_items_per_line`  \n\n  When printing a list or other iterables, you may want to limit how many items can be printed on a line to improve readability. *Default value is 10.* Note that for better readability I chose to insert a line break after every closing dictionary, list, tuple, set, frozenset and generator.\n\n- `varp.dict_items_per_line`  \n\n  Should be like `varp.iter_items_per_line` but I format the lenght of every key to the max lenght of all keys to achieve better readability when printing only one item per line so you need to set `varp.dict_alignment` to `'none'` to deactivate alignment.\n\n- `varp.dict_alignment`  \n\n  Default value is `'left'` but you might want to choose `'right'` or `'none'`. Keys and values are aligned as wished. If `'none'` is chosen there is no alignment. Also possible is a tuple containing to values, each beeing one of the mentioned three, to set the alignment for the key and the value seperately. \n\n- `varp.list_alignment`  \n\n  Same as `varp.dict_alignment` but for lists, tuples, sets, frozensets and generators and only with one value of `'left'`, `'right'` or `'none'`\n\n- `varp.color_preset(preset)`  \n\n  Getting different colors is as easy as calling `varp.color_preset` with the preset of your choice. There are a bunch of presets saved in `varpFore.all_presets`. Since every preset has the key 'name' you can choose a preset by name with `varpFore.get_preset_by_name(name)`. \n\n- `varp.show_all_color_presets`  \n\n  Calling this function will print out every color_preset saved in `varpFore.all_presets`.\n\n- `varp.show_current_color_preset`  \n\n  You guessed it this shows you your current color preset.  \n\n- `varp.save_current_color_preset`  \n\n  Don't like the available color presets? Save your own!\n\n- `varp.varname_rgb`  \n\n  r, g, b code for the variable name\n\n- `varp.name_value_sep_rgb`  \n\n  r, g, b code for the seperator of the variable naem and the value\n\n- `varp.value_rgb`  \n\n  r, g, b code for the value\n\n- `varp.comma_rgb`  \n\n  r, g, b code for the comma (or any varp.comma string)\n\n- `varp.prefix_rgb`  \n\n  r, g, b code for the prefix\n\n- `varp.dict_keys_rgb`  \n\n  r, g, b code for the dictionary keys\n\n- `varp.dict_vals_rgb`  \n\n  r, g, b code for dictionary values\n\n\n\n\n\n## Planned\n\nI plan on adding different colors for different nesting levels and more formatting cases for numpy and what not.  \n\nThere are problems fitting the output to the terminal but as soon as I have that figured out I will add it.\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Nicer printing with var_print: Colours and structure allow quick reading of the output, at the same time the name of the variable is displayed.",
    "version": "0.0.9",
    "project_urls": null,
    "split_keywords": [
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62ba7665d8e7f024772d0eada37057b9db2a798151c3dabec71585e4df335ebd",
                "md5": "6a1114050e0a78dcec3313fc07ce31ac",
                "sha256": "d93c3592c787f7e69bcd58ab5598c9cc2886fa3d2ad202df1de4efec05864640"
            },
            "downloads": -1,
            "filename": "var_print-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a1114050e0a78dcec3313fc07ce31ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14037,
            "upload_time": "2024-05-12T12:26:08",
            "upload_time_iso_8601": "2024-05-12T12:26:08.176180Z",
            "url": "https://files.pythonhosted.org/packages/62/ba/7665d8e7f024772d0eada37057b9db2a798151c3dabec71585e4df335ebd/var_print-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b1200d35f1ef302deba67dc6685c31a549f33c451a6d26cf3dbecc333dc8ccf",
                "md5": "a750624c062c9c5aa0f537b1dd1be175",
                "sha256": "bd22e32863f0d73566668e3b4cb07dea526891969a47fc90a5f0534ecb5dc197"
            },
            "downloads": -1,
            "filename": "var_print-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "a750624c062c9c5aa0f537b1dd1be175",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16794,
            "upload_time": "2024-05-12T12:26:09",
            "upload_time_iso_8601": "2024-05-12T12:26:09.799938Z",
            "url": "https://files.pythonhosted.org/packages/0b/12/00d35f1ef302deba67dc6685c31a549f33c451a6d26cf3dbecc333dc8ccf/var_print-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-12 12:26:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "var-print"
}
        
Elapsed time: 0.25267s