spect
Categorize the dir() of a python object.
Essentially filters Python's dir() built-in for a given object nicely. Might become a dir() pretty printer on steroids at some point and/or a nice helper for quick, interactive debugging / introspecting.
Usage
import spect
import re
respect = spect(re)
print(respect.dunder) # {'__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__'}
print(respect.private) # {'_compile', '_locale', '_alphanum_bytes', '_expand', '_alphanum_str', '_MAXCACHE', '_pickle', '_subx', '_pattern_type', '_compile_repl', '_cache'}
print(repsect.const_private) # {'_MAXCACHE'}
So far spect knows these categories:
-
regular:
varname -
alias:
varname_ -
dunder:
__varname__ -
private:
_varname -
superprivate:
__varname -
general: an alias for regular, so
varnameas well -
magic: double underscore delimitered (dunder) and callable (e.g.
__init__) -
const: any of the above as long as it has letters and all of them are uppercase (e.g.
_MAXCACHE)
The categories can be combined and are sets (as are their combinations):
-
const_dunder_superprivate: all that are either double underscore delimitered or superprivate and contain at least one upper case letter no lower case.
x = spect(...) x.const_dunder_superprivate == (x.dunder | x.superprivate) & x.const # True
-
private_alias: combination of alias and private from above, i.e. equivalent to the set notation:
x.private_alias == x.alias | x.private # True # has all in x.private and x.alias
Installation
python -m pip install --user spect
ToDo
- Make Python 2 compatible (maybe)
- Ponder getting magic methods from a list (version dependent!
hard to future-proof! but no false positives)
- Think about the use
callablefor Python versions 3.0 to 3.2 wherecallablewas deprecated
- Think about the use
- Maybe add a filter for
snake_case,camelCaseandPascalCase(kebab-casedoes not make for valid variable names)
Metadata
Release files for spect 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spect-0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for spect-0.3-py2.py3-none-any.whl |
Release files / spect-0.3-py2.py3-none-any.whl
| Download URL | spect-0.3-py2.py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3cf0202f35bb6ea96de0aba16e051cac16ac71287f8558be9d5c8d944b2f3434
|
|
BLAKE2b-256 checksum How to use checksums |
c0e6313b998253cfcfc19a04e7f887490a8b4991d8a4d60468326c99b812f6b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for spect 0.3
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.