Skip to main content

guide

Simple object to navigate complex python objects

To install: pip install guide

Examples

Object that provides a mapping interface to the attributes of python object.

The keys will be the names of the attributes and the values will be Attrs instances of said attributes.

>>> import guide
>>> from guide import Attrs
>>> a = Attrs(guide)
>>> sorted(a)  # you would usually use ``list`` instead of ``sorted`` but the latter is used for test consistency
['Attrs', 'ObjReader', 'base', 'util']
>>> aa = a['Attrs']
>>> sorted(aa)
['get', 'head', 'items', 'keys', 'module_from_path', 'update_keys_cache', 'values']

Here's how you could implement a generator of paths (tuples) of internal module of a given module:

from guide import Attrs
import inspect

def internal_modules(module, path=()):
    if not isinstance(module, Attrs):
        module = Attrs(module)
    prefix = module.src.__name__
    for k, v in module.items():
        if inspect.ismodule(v.src) and v.src.__name__.startswith(prefix):
            yield path + (k,)
            yield from internal_modules(v, path=path + (k,))
>>> import guide
>>> for path in internal_modules(guide):
...     print(path)
('tools',)
('tests',)
('tests', 'simple_tests')
('base',)
('util',)

Recursively collecting objects from modules, submodules, attributes...

The base function for this is guide.tools.recollect. The following submodule_callables is simply constructed from recollect.

>>> import guide
>>> print(*sorted(set(x.__name__ for x in guide.tools.submodule_callables(guide))), sep='\n')
Attrs
ObjReader
copy_attrs
internal_modules
is_an_obj_of_module
is_hashable
not_underscore_prefixed
recollect
submodule_callables

Metadata

Release files for guide 0.0.8

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

Source distribution (sdist)

Source distribution for guide 0.0.8
File Size Uploaded
guide-0.0.8.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 17.8 kB

Release files / guide-0.0.8.tar.gz

Download URL guide-0.0.8.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e4e8f585a619e226a1edd0304ec924cb03b7d70159386c6a7e84656414a4a832
BLAKE2b-256 checksum
How to use checksums
d1d8cbec04e4ad914584aeebbb9188cfcd9904adbe76e0dd5979057022954afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release files / guide-0.0.8-py3-none-any.whl

Download URL guide-0.0.8-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c55485d814c964bb86cc66d767d5d11a7ffd3e0f144ad6ebb632c3fad99efd71
BLAKE2b-256 checksum
How to use checksums
64a2246c2635617b42febaa16aa5e5e7e5b5190b5846cc2475d3b7a6c52132f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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