Skip to main content

ANPlusB

This tiny package provides a toolkit for working with the <An+B> CSS microsyntax.

Installation

This package is available on PyPI:

$ pip install a-n-plus-b

Usage

This package only ever parses the <An+B> microsyntax. It does not support the of <selector> syntax.

Examples

>>> from a_n_plus_b import ANPlusB
>>> ANPlusB(2, 1)
ANPlusB(2n+1)
>>> str(_)
'2n+1'
>>> ANPlusB(4)
ANPlusB(4)
>>> ANPlusB(4, 0)
ANPlusB(4n)
>>> {ANPlusB(1, 0), ANPlusB(True, False)}
{ANPlusB(n)}
>>> from itertools import islice
>>> ANPlusB(3, 2)
ANPlusB(3n+2)
>>> values = _.values()
>>> values
_InfiniteRange(start = 2, step = 3)
>>> list(islice(values, 10))
[2, 5, 8, 11, 14, 17, 20, 23, 26, 29]
>>> 6405429723686292014 in values
True
>>> instance = ANPlusB(4, -7)
>>> list(instance.indices(40))
[1, 5, 9, 13, 17, 21, 25, 29, 33, 37]
>>> list(instance.indices(40, from_last = True))
[40, 36, 32, 28, 24, 20, 16, 12, 8, 4]
>>> list(instance.indices(40, order = 'descending'))
[37, 33, 29, 25, 21, 17, 13, 9, 5, 1]
>>> list(instance.indices(40, from_last = True, order = 'ascending'))
[4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
>>> ANPlusB.parse('odd')
ANPlusB(2n+1)
>>> ANPlusB.parse('even')
ANPlusB(2n)
>>> ANPlusB.parse('4')
ANPlusB(4)
>>> ANPlusB.parse('-1n')
ANPlusB(-n)
>>> ANPlusB.parse('+0n-8')
ANPlusB(-8)
>>> ANPlusB.parse('0n+0124')
ANPlusB(124)
>>> ANPlusB.from_complex(5j - 2)
ANPlusB(5n-2)
>>> from a_n_plus_b import n
>>> 2 * n
ANPlusB(2n)
>>> n * -3 - 1
ANPlusB(-3n-1)
>>> 4 - n * 9
ANPlusB(-9n+4)

Contributing

Please see Contributing for more information.

Release files for a-n-plus-b 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a-n-plus-b 0.2.0
File Size Uploaded
a_n_plus_b-0.2.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a-n-plus-b 0.2.0
File Interpreter ABI Platform
a_n_plus_b-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / a_n_plus_b-0.2.0.tar.gz

Download URL a_n_plus_b-0.2.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
379248ee6e91d974495416929abbe389ae2c8ed901b0b6a9088f1b889381f2b4
BLAKE2b-256 checksum
How to use checksums
f388f25c24b21f8cfc5caca363e064a04fb3df89294ac5d888fcfd39279acbc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release files / a_n_plus_b-0.2.0-py3-none-any.whl

Download URL a_n_plus_b-0.2.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
823df5f43aadc08b1a002424528269271269c90552b68cb2527c789e1c8e0884
BLAKE2b-256 checksum
How to use checksums
ecb897697f09e2ab2fd05fd86d743316a9f8b7e36fd81dd664b92d63feb80336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page