Skip to main content

Python Object Type Definitions

Runavelo adds the following types to the Python environment. You can use them without importing a module.

ExcelApp

class ExcelApp:
pass

WordApp

class WordApp:
pass

SQLConnection


class SQLConnection:
pass

MyList


class MyList(list):
@property
def length(self):
return len(self)

@property
def first(self):
if len(self) == 0:
raise Exception("List has no data")
return self[0]

@property
def last(self):
if len(self) == 0:
raise Exception("List has no data")
return self[-1]

@property
def center(self):
count = len(self)
if count == 0:
raise Exception("List has no data")
return self[count // 2]


def __str__(self):
s = f"""[list]"""
for index, item in enumerate(self):
s = f"""{s}
{index} {item}"""
return s


Map

class Map(dict):
@property
def length(self):
return len(self)


def __str__(self):
s = f"""[mapping]"""
for index, (key, value) in enumerate(self.items()):
s = f"""{s}
{index} {key}:{value}"""
return s


def __getattr__(self, key):
try:
return self[key]
except KeyError:
raise AttributeError(f"No {key}")


def __setattr__(self, key, value):
self[key] = value