Skip to main content

A small module for parsing and evaluating expressions of any number of variables

Project description

How to Use:

After importing ‘mathfuncs_parse’, create a ‘mathfuncs_parse.func(expr: str)’ object.

Available Member Functions:

  • valid() -> bool Checks whether the expression is syntactically correct.

  • eval() -> float Evaluates the expression. Note: only works if no variables are present.

  • eval(vars: dict{str: float|int}) -> float Evaluates the expression, substituting the variables present with the values passed in the dict.

  • vars() -> dict{str: float} Returns a dict containing all variables that must be passed to eval().

  • add_func(name: str, func: <functionObj(float) -> float>) -> Null Adds a user-defined function to the object’s internal state. Note: calling ‘init(str)’ does not reset this.

  • avail_funcs() -> dict{str: <functionObj>} Returns a dict of available functions which can be used in the current expression.

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

mathfuncs-parse-1.1.3.tar.gz (181.4 kB view details)

Uploaded Source

File details

Details for the file mathfuncs-parse-1.1.3.tar.gz.

File metadata

  • Download URL: mathfuncs-parse-1.1.3.tar.gz
  • Upload date:
  • Size: 181.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mathfuncs-parse-1.1.3.tar.gz
Algorithm Hash digest
SHA256 027798e769f4e66d30b014be9b0e99adb1c0622d21358822d18fbc390de0f509
MD5 d6cc9e6702da7651023a7785b435e8e1
BLAKE2b-256 a6b32cf47753b2c47994df8ee54860a63f253b1d58fd401070879a53406cee17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page