Skip to main content

HowIGotHere

A package containing a single function howigothere that returns a condensed stack preview. Useful for debugging to easily trace how some call was made, even through a jungle of calls made by frameworks and other packages.

To see it in action, you can run example.py or, if you didn't install the package but you only downloaded this repository, ./try_me.sh example.py. Both approaches require that settings-collector is installed. The result should look like this:

Screenshot

Content

  1. The name
  2. Usage
  3. Global setup
  4. Local setup

The name

The name of the package is "How I Got Here?". If your question is "How I Go There?", wherever "there" might be, you'll need to ask some other package.

Usage

Make an import:

from howigothere import howigothere

and then call

print(howigothere())  # or logger.debug(howigothere())

somewhere in your code.

Global setup

This package relies on settings-collector to collect settings from various frameworks. This means that you can set it up through standard mechanisms of the framework used by your project.

For example, if you are using Django, you can set the separator colour by defining HOWIGOTHERE__COLOR_SEP (note two underscores before COLOR, but only one after it) in your Django settings. The frameworks' settings character casing is respected, so - for example - in TurboGears this will be howigothere__color_sep

If you don't use a framework (or, at least, not one supported by settings-collector), you can also use sc_settings (settings-collector's dict-like equivalent of frameworks' configs) and do something this:

from settings_collector import sc_settings

sc_settings["howigothere__color_sep"] = colorama.Fore.RED

For more details, please see the documentation of settings-collector.

If the setup (either in sc_settings or in framework's settings) contains settings-collector's scopes, you can specify the scope to use like this:

howigothere(namespace="some_scope")

Local setup

Lastly, you can also configure values when calling the function. For example,

howigothere(color_sep=colorama.Fore.RED)

Here is the list of all arguments accepted by the function. All but namespace are also available in sc_settings and frameworks' settings. The default values are as shown, unless overridden in sc_settings or framework's setup.

  • namespace [default: None]: If set, it is used as scope identifier in settings_collector.
  • keep_dirs [default: 1]: The number of directories to keep in output (None to keep them all). For example, if set to 2, path /a/b/c/d/e/f.py will be displayed as d/e/f.py. This is to reduce the output while still being able to distinguish between files with the same name.
  • sep [default: " > "]: Separator between calls.
  • call_format [default: "{function} ({path}:{lineno})"]: The format of each call.
  • no_color [default: False]: If set to True, colours won't be used even if they are properly defined. This is useful if you want to have properly coloured printouts most of the times, but you sometimes want to add these to some logging system that doesn't support your preferred way of colouring text.
  • start_from_dir [default: None]: If set, output is suppressed until the first file having start_from_dir as its parent. This can also be a tuple of strings, in which case encountering any of them starts the output.

To add to those, colours can also be redefined. Their defaults depend on the presence of colorama package (if it's not there, these are all empty strings by default). The displayed defaults assume that colorama is installed and that its Fore and Style constants are imported.

  • color_reset [default: Style.RESET_ALL]: This is added to the end of each colourisable chunk (separator, function name, etc.).
  • color_sep [default: "", i.e., no colouring]: The colour used for the separators between calls.
  • color_func[ default: Style.BRIGHT + Fore.GREEN]: The colour used for functions' names in each call.
  • color_path [default: Style.BRIGHT + Fore.CYAN]: The colour used for path of the each file containing called functions.
  • color_lineno [default: Fore.CYAN]: The colour used for the line numbers where calls were made.

There is also support for showing arguments to calls in the stack, turned off by default for backwards compatibility. The arguments controlling this are:

  • show_args [default: False]: A switch determining if the arguments should be shown or not.
  • color_arg_name [default: Style.BRIGHT + Fore.BLUE]: The colour used for arguments' names.
  • color_arg_eq [default: Style.BRIGHT + Fore.GREEN]: The colour used for the equality sign between arguments' names and values.
  • color_arg_value [default: Style.BRIGHT + Fore.YELLOW]: The colour used for arguments' values.

Metadata

Release files for howigothere 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for howigothere 1.1.0
File Size Uploaded Provenance Actions
howigothere-1.1.0.tar.gz 22.8 kB Without provenance Details for howigothere-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for howigothere 1.1.0
File Interpreter ABI Platform Actions
howigothere-1.1.0-py3-none-any.whl Python 3 none any Details for howigothere-1.1.0-py3-none-any.whl

Total release size: 29.5 kB

Release files / howigothere-1.1.0.tar.gz

Download URL howigothere-1.1.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9459e4a92594835d3e95c5f2c4dfb53dc528874e3b1d2e861038d784625eb129
BLAKE2b-256 checksum
How to use checksums
17101c90ea0b91a8b4148af903afdaa9c2a44855507128388ee4b6cd852ec6ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / howigothere-1.1.0-py3-none-any.whl

Download URL howigothere-1.1.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee6ec0e4eec6b08b807f4572b024bfacb5f88aa1b53c144283532555fb36dde3
BLAKE2b-256 checksum
How to use checksums
0c878e2a7da60f777de848a7305bc472ddd5c667eca538ca007c9660a4a52590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Security for howigothere 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page