Extend the ``inspect`` standard library.
Project description
Welcome to inspect_mate Documentation
inspect_mate can easily separate:
regular attribute.
property attribute.
regular method.
static method.
class method.
all attributes, include regular attribute and property attribute.
all methods, include regular method, static method and class method.
Quick Links
Example
import:
from inspect_mate import (
is_attribute,
is_property_method,
is_regular_method,
is_static_method,
is_class_method,
get_attributes,
get_property_methods,
get_regular_methods,
get_static_methods,
get_class_methods,
get_all_attributes,
get_all_methods,
)
define a class:
class Base(object):
attribute = "attribute"
def __init__(self):
self.initiated_attribute = "initiated_attribute"
@property
def property_method(self):
return "property_method"
def regular_method(self):
return "regular_method"
@staticmethod
def static_method():
return "static_method"
@classmethod
def class_method(cls):
return "class_method"
class Klass(Base):
pass
instance = Klass()
usage:
# tester_function(klass_or_instance, "attribute_name")
>>> is_attribute(Klass, "attribute")
True
>>> is_property_method(Klass, "property_attribute")
True
>>> is_regular_method(Klass, "regular_method")
True
>>> is_static_method(Klass, "static_method")
True
>>> is_class_method(Klass, "class_method")
True
>>> is_attribute(instance, "attribute")
True
>>> is_attribute(instance, "initiated_attribute")
True
>>> is_property_method(instance, "property_attribute")
True
>>> is_regular_method(instance, "regular_method")
True
>>> is_static_method(instance, "static_method")
True
>>> is_class_method(instance, "class_method")
True
# getter_function(klass_or_instance), yield (attr, value)
>>> get_attributes(Klass)
[("attribute", "attribute")]
>>> get_property_methods(Klass)
[("property_attribute", "property_attribute")]
>>> get_regular_methods(Klass)
[("regular_method", Klass.regular_method)]
>>> get_static_methods(Klass)
[("static_method", "Klass.static_method")]
>>> get_class_methods(Klass)
[("class_method", "Klass.class_method")]
>>> get_all_attributes(Klass)
[("attribute", "attribute"), ("property_attribute", "property_attribute")]
>>> get_all_methods(Klass)
[("regular_method", Klass.regular_method), ("static_method", "Klass.static_method"), ("class_method", "Klass.class_method")]
Install
inspect_mate is released on PyPI, so all you need is:
$ pip install inspect_mate
To upgrade to latest version:
$ pip install --upgrade inspect_mate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
inspect_mate-0.0.2.tar.gz
(13.4 kB
view details)
Built Distribution
File details
Details for the file inspect_mate-0.0.2.tar.gz
.
File metadata
- Download URL: inspect_mate-0.0.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a51907976d9624d0eeaf0d2207a67c95d174a2fa3aabfdaee53eeaf91d973bdd |
|
MD5 | 80854ca0a6523378aae58cf6e31adfbe |
|
BLAKE2b-256 | 3d0e75bcfbb04eb18002ac864014b3a88a0615a3b90e3f3aa9cb9067503906bd |
File details
Details for the file inspect_mate-0.0.2-py2-none-any.whl
.
File metadata
- Download URL: inspect_mate-0.0.2-py2-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de7e5eb9f8231e741661aadbdbd2ae1b6e607241705abad9695790fd5c9440ab |
|
MD5 | d545d5eddf765ae2c9f701cea4fa3a58 |
|
BLAKE2b-256 | fac1c1bd37367766779c3b218eadce19c7da8901392d18d2ef94ac41dda782ce |