<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# name:             meta.py
# author:           <NAME>
# email:            <EMAIL>
# created on:       01/28/2016
#

"""
ext_pylib.meta.meta
~~~~~~~~~~~~~~~~~~~

Classes and functions for meta-programming with python.
This is mostly experimental stuff. For now, class DynamicProperty is merely a
close reimplementation of python's native property().

Credit for much of this goes to:
    http://eev.ee/blog/2012/05/23/python-faq-descriptors/
"""


class DynamicProperty(object):
    """A re-implementation of python's native property().
    Most of this code derived from: http://eev.ee/blog/2012/05/23/python-faq-descriptors/."""
<commit_msg>Adds usage example.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# name:             meta.py
# author:           <NAME>
# email:            <EMAIL>
# created on:       01/28/2016
#

"""
ext_pylib.meta.meta
~~~~~~~~~~~~~~~~~~~

Classes and functions for meta-programming with python.
This is mostly experimental stuff. For now, class DynamicProperty is merely a
close reimplementation of python's native property().

Credit for much of this goes to:
    http://eev.ee/blog/2012/05/23/python-faq-descriptors/
"""


class DynamicProperty(object):
    """A re-implementation of python's native property().
    Most of this code derived from: http://eev.ee/blog/2012/05/23/python-faq-descriptors/.

    :param getter: The getter function of the property.

    Usage::

        >>> from ext_pylib.meta import DynamicProperty

        >>> def getter_func(self):
        >>>     return self._property

        >>> def setter_func(self, value):
        >>>     self._property = value

        >>> class Cls(object): pass
        >>> instance = Cls()
        >>> instance.__class__.new_property = DynamicProperty(getter_func)
        >>> instance.__class__.new_property = \
                instance.__class__.new_propety.create_setter(setter_func)

        >>> instance.new_property = 'value'
        >>> instance.new_property
        'value'
    """

{'fraction_non_alphanumeric': 0.14396509936984975, 'fraction_numerical': 0.024236548715462918, 'mean_word_length': 2.7256317689530687, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7449382', 'n_tokens_mistral': 659, 'n_tokens_neox': 600, 'n_words': 161}