Skip to main content

iterpop makes popping the value out of a singleton container safe and fun

Project description

iterpop

https://img.shields.io/pypi/v/iterpop.svg https://img.shields.io/travis/mmore500/iterpop.svg Documentation Status

iterpop makes popping the value out of a singleton container or a homogeneous container safe & fun

from iterpop import iterpop as ip

# returns 'a'
ip.popsingleton(['a'])
ip.popsingleton({'a'})
ip.popsingleton('a')

# throws
ip.popsingleton([])
ip.popsingleton(set())
ip.popsingleton('')

# throws
ip.popsingleton(['a', 'b'])
ip.popsingleton({'a', 'b'})
ip.popsingleton('ab'})

# returns 'a'
ip.pophomogeneous(['a'])
ip.pophomogeneous({'a'})
ip.pophomogeneous('a')

# also returns 'a'
ip.pophomogeneous(['a', 'a'])
ip.pophomogeneous('aaa')
ip.pophomogeneous('a' for __ in range(100))

# throws
ip.pophomogeneous([])
ip.pophomogeneous(set())
ip.pophomogeneous('')

# throws
ip.pophomogeneous(['a', 'b'])
ip.pophomogeneous({'a', 'b'})
ip.pophomogeneous('ab'})

# returns 'a'
ip.poursingleton(['a'])
ip.poursingleton({'a'})
ip.poursingleton('a')

# returns None
ip.poursingleton([])
ip.poursingleton(set())
ip.poursingleton('')

# throws
ip.poursingleton(['a', 'b'])
ip.poursingleton({'a', 'b'})
ip.poursingleton('ab'})

# returns 'a'
ip.pourhomogeneous(['a'])
ip.pourhomogeneous({'a'})
ip.pourhomogeneous('a')

# also returns 'a'
ip.pourhomogeneous(['a', 'a'])
ip.pourhomogeneous('aaa')
ip.pourhomogeneous('a' for __ in range(100))

# returns None
ip.pourhomogeneous([])
ip.pourhomogeneous(set())
ip.pourhomogeneous('')

# throws
ip.pourhomogeneous(['a', 'b'])
ip.pourhomogeneous({'a', 'b'})
ip.pourhomogeneous('ab'})

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-07-06)

  • First release on PyPI.

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

iterpop-0.4.1.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

iterpop-0.4.1-py2.py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 2 Python 3

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