{"id":18964543,"url":"https://github.com/pyparsing/plusminus","last_synced_at":"2026-02-27T21:44:22.657Z","repository":{"id":50841313,"uuid":"230125157","full_name":"pyparsing/plusminus","owner":"pyparsing","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-11T13:18:01.000Z","size":311,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T06:55:42.977Z","etag":null,"topics":["arithmetic-expression-evaluator","evaluate-expressions","infix-evaluation","infix-expression-parser","infix-notation","parsing","parsing-library","python","python-3","python3","python3-library","safe-evaluation"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyparsing.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-25T16:09:56.000Z","updated_at":"2025-01-30T13:54:28.000Z","dependencies_parsed_at":"2024-11-16T11:04:59.661Z","dependency_job_id":null,"html_url":"https://github.com/pyparsing/plusminus","commit_stats":{"total_commits":146,"total_committers":4,"mean_commits":36.5,"dds":"0.36986301369863017","last_synced_commit":"6c557498ac61190b21adb2cef64e1691b11a84a5"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyparsing%2Fplusminus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyparsing%2Fplusminus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyparsing%2Fplusminus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyparsing%2Fplusminus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyparsing","download_url":"https://codeload.github.com/pyparsing/plusminus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023713,"owners_count":21199958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic-expression-evaluator","evaluate-expressions","infix-evaluation","infix-expression-parser","infix-notation","parsing","parsing-library","python","python-3","python3","python3-library","safe-evaluation"],"created_at":"2024-11-08T14:24:58.849Z","updated_at":"2026-02-27T21:44:17.635Z","avatar_url":"https://github.com/pyparsing.png","language":"Python","readme":"# plusminus\n\nThe **plusminus** package provides a ready-to-run arithmetic parser and evaluator, \nbased on [`pyparsing`](https://pyparsing-docs.readthedocs.io/en/latest/index.html)'s \n[`infix_notation`](https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.html#pyparsing.infixNotation) \nhelper method.\n\nStrings containing 6-function arithmetic expressions can be parsed and evaluated using the \n[`ArithmeticParser`](https://github.com/pyparsing/plusminus/blob/master/doc/arithmetic_parser.md#the-core-basicarithmeticparser):\n\n```python\nfrom plusminus import BaseArithmeticParser\n\nparser = BaseArithmeticParser()\nprint(parser.evaluate(\"2+3/10\"))\n```\n\nThe parser can also return an Abstract Syntax Tree of `ArithNode` objects:\n\n```python\nparsed_elements = parser.parse(\"2+3/10\")\n```\n\nArithmetic expressions are evaluated following standard rules for operator precedence, allowing for use of parentheses to override:\n\n    ()\n    |x|\n    ∩ \u0026 ∪ | - ^ ∆ (set operations)\n    **\n    -\n    * / // × ÷ mod\n    + -\n    \u003c \u003e \u003c= \u003e= == != ≠ ≤ ≥\n    in ∈ ∉ (element in/not in set)\n    not\n    and ∧\n    or ∨\n    ? : (ternary)\n\nFunctions can be called:\n\n    abs    ceil   max\n    round  floor  str\n    trunc  min    bool\n\n\nThe `BaseArithmeticParser` also supports assignment of variables:\n\n    r = 5\n    area = π × r²\n\n\nThis last expression could be assigned using  `@=` formula assignment:\n\n    area @= π × r²\n\n\nAs `r` is updated, evaluating `area` will be reevaluated using the new value.\n\n\nAn `ArithmeticParser` class is also defined, with more extensive operators, \nincluding:\n\n    !     - factorial  \n    °     - degree-radian conversion\n    √ ⁿ√  - square root and n'th root (2-9)\n    ⁻¹  ⁰  ¹  ²  ³ - common exponents as superscripts\n\nand additional pre-defined functions:\n\n    sin    asin  rad    gcd\n    cos    acos  deg    lcm\n    tan    atan  ln     rnd\n    sgn    sinh  log    randint\n    gamma  cosh  log2\n    hypot  tanh  log10\n\nThis parser class can be used in applications using algebra or trigonometry\nexpressions.\n\nCustom expressions can be defined using a simple\n[`API`](https://github.com/pyparsing/plusminus/blob/master/doc/developer_api.md).\nExample parsers are included for other specialized applications\nand domains:\n\n- dice rolling (`\"3d6 + d20\"`)\n- time delta expressions (`\"today() + 2d + 12h\"`)\n- retail and business expressions (`\"20% off of 19.99\"`)\n- combinatoric expressions (`\"6C2\"` or `\"5P3\"` )\n \n\nThese parsers can be incorporated into other\napplications to support the safe evaluation of user-defined domain-specific\nexpressions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyparsing%2Fplusminus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyparsing%2Fplusminus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyparsing%2Fplusminus/lists"}