skip to navigation
skip to content

getattr 0.0.26

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

.. 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  
File Type Py Version Uploaded on Size
getattr-0.0.26.tar.gz (md5) Source 2017-12-07 2KB