Coming Soon — This feature is currently in development and not yet available. This guide is a preview of what's coming.
AirScript is a limited-feature version of Python — it has the same syntax and semantics, but runs in a secure sandbox with a restricted set of built-ins and no access to the broader Python ecosystem. This guide explains exactly what is available.
Modules
| Module |
Description |
json |
Parse and generate JSON. Use json.loads(text) and json.dumps(obj). |
re |
Regular expressions. Use re.search(), re.findall(), re.sub() to match and extract patterns from text. |
math |
Mathematical functions: math.floor(), math.ceil(), math.sqrt(), math.isnan(), etc. |
decimal |
Precise decimal arithmetic. Use decimal.Decimal("19.99") for currency and financial values to avoid floating-point errors. |
time |
Low-level time functions. Use time.time() for a Unix timestamp, time.sleep(n) for delays. |
datetime |
Date and time objects with arithmetic and formatting. Use datetime.datetime.now(), datetime.date.today(), datetime.timedelta(days=7), etc. Prefer this over time for working with dates. |
zoneinfo |
Timezone support for datetime objects. Use zoneinfo.ZoneInfo("Australia/Sydney") to create timezone-aware datetimes. |
calendar |
Calendar utilities. Use calendar.monthrange(year, month) to get the number of days in a month, or calendar.isleap(year) to check for leap years. |
collections |
Useful data structures: collections.Counter for counting items, collections.defaultdict for dicts with defaults. |
itertools |
Iteration utilities: itertools.chain(), itertools.groupby(), itertools.islice(), etc. |
functools |
Functional utilities: functools.reduce() to accumulate a list into a single value. |
base64 |
Base64 encoding/decoding. Use base64.b64encode(bytes) and base64.b64decode(str). Often needed for API authentication headers. |
hashlib |
Cryptographic hashing: hashlib.sha256(data).hexdigest(). Use for generating checksums or API signatures. |
hmac |
HMAC message authentication. Use hmac.new(key, message, hashlib.sha256).hexdigest() for signed API requests. |
string |
String constants: string.ascii_letters, string.digits, string.punctuation. Useful for validation and generating identifiers. |
textwrap |
Text wrapping and truncation. Use textwrap.shorten(text, width=200) to trim long strings before sending to the LLM. |
unicodedata |
Unicode character database. Use unicodedata.normalize("NFC", text) to normalise international text input. |
urllib.parse |
URL encoding utilities. Use urllib.parse.urlencode(params), urllib.parse.quote(string), urllib.parse.urlparse(url). Note: only urllib.parse is available — network access via urllib.request is not permitted. |
Types & Constructors
| Function |
Description |
str, int, float, bool |
Convert values to string, integer, float, or boolean. |
list, dict, set, tuple |
Create or convert to these collection types. |
Collections & Iteration
| Function |
Description |
len(x) |
Return the length of a sequence or collection. |
range(...) |
Generate a sequence of numbers. |
enumerate(iterable) |
Iterate with index and value. |
zip(...) |
Combine multiple iterables element-wise. |
map(fn, iterable) |
Apply a function to each element. |
filter(fn, iterable) |
Filter elements by a predicate. |
sorted(iterable) |
Return a sorted list. |
reversed(sequence) |
Iterate in reverse order. |
Math & Comparison
| Function |
Description |
min(...), max(...) |
Return the smallest or largest value. |
sum(iterable) |
Sum all values in an iterable. |
abs(x) |
Return the absolute value. |
round(x, n) |
Round to n decimal places. |
Introspection
| Function |
Description |
isinstance(obj, type) |
Check if an object is an instance of a type. |
type(obj) |
Get the type of an object. |
hasattr(obj, name) |
Check if an object has an attribute. |
getattr(obj, name) |
Get an attribute from an object. |
setattr(obj, name, value) |
Set an attribute on an object. |
Exception Types
These exception types are available for use in try/except blocks:
| Exception |
Description |
Exception |
Base exception class. |
ValueError |
Raised when a value is invalid. |
TypeError |
Raised when a type is incorrect. |
KeyError |
Raised when a dictionary key is not found. |
IndexError |
Raised when a sequence index is out of range. |
AttributeError |
Raised when an attribute is not found. |
Constants
| Name |
Description |
True, False, None |
Boolean and null constants. |
Not Available
For security, these are not available: import, open, exec, eval, compile, globals, locals, __import__, and file/network access outside of air.http_get(), air.http_post(), and air.http_request().
If your use case requires additional built-ins or modules, please contact the Airgentic team — we may be able to add them.
← Back to Functions overview | AirScript Functions