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 hashes)

Uploaded Python 2 Python 3

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