Skip to main content

Check if objects have same attrs at collections.abc types.

Project description

HasAttrs

A pure python package used to check if objects have the same attrs as collections.abc types.

Description

Use HasAttrs to check if objects have the same attributes as the classes in collections.abs, such as Mapping and MutableSequence. HasAttrs has no dependencies outside Python.

Getting Started

Dependencies

  • Python>=3.6

Installing

  • pip install hasattrs

Executing program

  • How to run the program
  • Step-by-step bullets
from collections.abc import Mapping
from hasattrs import has_mapping_attrs
from hasattrs import has_abc_attrs

class Map:
    def __getitem__(self, key): ...
    def __iter__(self): ...
    def __len__(self): ...
    def __contains__(self, value): ...
    def keys(self): ...
    def items(self): ...
    def values(self): ...
    def get(self, key): ...
    def __eq__(self, other): ...
    def __ne__(self, other): ...

# isinstance does not work for Mapping
isinstance(Map(), Mapping) -> False

# but hasattrs has_mapping_attrs does work
has_mapping_attrs(Map()) -> True

# has_abc_attrs also works by passing in collections.abc classes
has_abc_attrs(Map(), Mapping) -> True

Authors

Contributors names and contact info

Odos Matthews: odosmatthews@gmail.com

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Download files

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

Source Distribution

hasattrs-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

hasattrs-0.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file hasattrs-0.0.2.tar.gz.

File metadata

  • Download URL: hasattrs-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for hasattrs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8961f30fc0b1aa5b13f778a84326feeb1cec9d0c5e62b42cca0cface12e68cd2
MD5 a621f2cb71dcf00cad8fe2259324f2ee
BLAKE2b-256 cc2cbf44513a486da35037bb7c5b9716eb055aa158a5fd0145d01be9a9b94355

See more details on using hashes here.

File details

Details for the file hasattrs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: hasattrs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for hasattrs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b285a83e54670ddd7c86baaa4a200223cf7d9b75167709723b948358f1870fc
MD5 723bfea567f7ec257aae4b2c253b7829
BLAKE2b-256 b816ed300b60519849c3054702f92171070b969318722f83b8634da567484177

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