Skip to main content

getattr(object,name,default=None) function - builtin getattr replacement

Project description

.. README generated with readmemako.py (github.com/russianidiot/readme-mako.py) and .README dotfiles (github.com/russianidiot-dotfiles/.README)
.. image:: https://img.shields.io/badge/Language-Python-blue.svg?style=plastic
:target: none
.. image:: https://img.shields.io/pypi/pyversions/getattr.svg
:target: https://pypi.org/pypi/getattr
.. image:: https://img.shields.io/pypi/v/getattr.svg
:target: https://pypi.org/pypi/getattr
|
.. image:: https://api.codacy.com/project/badge/Grade/20631eeeed434a78a1e6565032a4ed15
:target: https://www.codacy.com/app/russianidiot/getattr-py
.. image:: https://codeclimate.com/github/russianidiot/getattr.py/badges/gpa.svg
:target: https://codeclimate.com/github/russianidiot/getattr.py
.. image:: https://landscape.io/github/russianidiot/getattr.py/master/landscape.svg?style=flat
:target: https://landscape.io/github/russianidiot/getattr.py
.. image:: https://scrutinizer-ci.com/g/russianidiot/getattr.py/badges/quality-score.png?b=master
:target: https://scrutinizer-ci.com/g/russianidiot/getattr.py/
|
.. image:: https://scrutinizer-ci.com/g/russianidiot/getattr.py/badges/build.png?b=master
:target: https://scrutinizer-ci.com/g/russianidiot/getattr.py/
.. image:: https://semaphoreci.com/api/v1/russianidiot/getattr-py/branches/master/badge.svg
:target: https://semaphoreci.com/russianidiot/getattr-py
.. image:: https://api.travis-ci.org/russianidiot/getattr.py.svg?branch=master
:target: https://travis-ci.org/russianidiot/getattr.py/
.. image:: https://app.wercker.com/status/ff2493c65e1d57a383916d5d97dc5d23/s/master
:target: https://app.wercker.com/russianidiot/getattr.py
Install
```````
.. code:: bash
`[sudo] pip install getattr`
Features
````````
* builtin function **getattr** replacement with same syntax
* extended **AttributeError** messages if attr not exists
Usage
`````
.. code:: python
>>> from getattr import getattr
>>> getattr(object,name,default=None)
Examples
````````
.. code:: python
# module
import os
>>> builtins.getattr(os,"not-existing")
AttributeError: 'module' object has no attribute 'not-existing'
>>> getattr.getattr(os,"not-existing")
AttributeError: module 'os' has no attribute 'not-existing'
# function
>>> builtins.getattr(function,"not-existing")
AttributeError: 'function' object has no attribute 'not-existing'
>>> getattr.getattr(function,"not-existing")
AttributeError: function '__main__.function' has no attribute 'not-existing'
# class
>>> class CLS: pass
>>> builtins.getattr(CLS,"not-existing")
AttributeError: type object 'CLS' has no attribute 'not-existing'
>>> getattr.getattr(CLS,"not-existing")
AttributeError: class '__main__.CLS' has no attribute 'not-existing'
# class object
>>> builtins.getattr(CLS(),"not-existing")
AttributeError: 'CLS' object has no attribute 'not-existing'
>>> getattr(CLS(),"not-existing")
AttributeError: __main__.CLS object has no attribute 'not-existing'
Feedback |github_follow| |github_issues|
.. |github_follow| image:: https://img.shields.io/github/followers/russianidiot.svg?style=social&label=Follow
:target: https://github.com/russianidiot
.. |github_issues| image:: https://img.shields.io/github/issues/russianidiot/getattr.py.svg
:target: https://github.com/russianidiot/getattr.py/issues

Release history Release notifications

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.0.34

History Node

0.0.33

History Node

0.0.32

History Node

0.0.31

History Node

0.0.30

History Node

0.0.29

History Node

0.0.28

This version
History Node

0.0.26

History Node

0.0.25

History Node

0.0.24

History Node

0.0.22

History Node

0.0.21

History Node

0.0.16

History Node

0.0.15

History Node

0.0.14

History Node

0.0.13

History Node

0.0.12

History Node

0.0.11

History Node

0.0.10

History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.2

History Node

0.0.1

History Node

0.0.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
getattr-0.0.26.tar.gz (2.8 kB) Copy SHA256 hash SHA256 Source None Dec 7, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page