As this function show up in several scripts. I guess you can add it to aexpect.py as a new function.