Skip to main content

Categorize the members of a python object.

Project description

spect

Categorize the members of a python object.

Usage

import spect
import re

respect = spect(re)
print(respect.dunder)
print(respect.private)
# output:
# {'__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__'}
# {'_compile', '_locale', '_alphanum_bytes', '_expand', '_alphanum_str', '_MAXCACHE', '_pickle', '_subx', '_pattern_type', '_compile_repl', '_cache'}

So far it knows these categories:

  • private: _varname
  • superprivate: __varname
  • alias: varname_
  • dunder: __varname__
  • regular: varname
  • magic: double underscore delimetered (dunder) and callable
  • 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 delimetered or superprivate and contain no lower case letters. That is equivalent to:

    x = spect(...)
    (x.dunder | x.superprivate) & x.const
    
  • prinvate_alias: alias or private, i.e. x.alias | x.private

Installation

python -m pip install --user spect

ToDo

  • Make Python 2 compatible (maybe)
  • Convert basic tests to pytest ones
  • Auto-build, test and upload to pypi on commit
  • Ponder getting magic methods from a list (version dependent!)
  • Think about callable and Python 3.0 to 3.2 where it was deprecated

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

spect-0.2-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file spect-0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: spect-0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

File hashes

Hashes for spect-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 21a701b339d0d96a7aca497ac72ccc04428845d04118e4d31254df9f306dcaa9
MD5 af65b8f7f6aae67be22d64ba42665f95
BLAKE2b-256 84809ecd89b3fe7fe43dcb3edc0999be968be44b66fa475675266bbe1da0b99d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page