implement Araq's suggestion: implement a macro for ~ such that
~py_import("os").getcwd() replaces the dot with a getattr.