Skip to main content

Get operator information.

Project description

Operator Information Library

The library to get information about various operators in Python.

Install through pip:

pip install o

Start off my importing the module:

import o

Use the get method to get the Operator object for a specific operator, provided as a string.

operator = o.get("+=")
print(operator)
>>> "<class 'Operator(operator='+=', name='addition assignment', type=AssignmentOperatorType, methods=['__iadd__'], function=operator.iadd)'>"

Use the various attributes to retrieve information for the operator.

operator.methods
>>> ['__iadd__']

str(operator.type)
>>> "assignment"

isinstance(operator.type, o.AssignmentOperatorType)
>>> True

Or, you can use the Operator object directly. Be careful, an unknown operator raises an UnknownOperator exception.

License

This repo is under the MIT license.

Supported by

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