+
+- bool have_addtofunc(Node *n) {
+- String* str = Getattr(n, "feature:addtofunc");
++ bool have_pythonappend(Node *n) {
++ String* str = Getattr(n, "feature:pythonappend");
+ return (str != NULL && Len(str) > 0);
+ }
+
+ /* ------------------------------------------------------------
+- * addtofunc()
+- * Get the %addtofunc code, stripping off {} if neccessary
++ * pythonappend()
++ * Get the %pythonappend code, stripping off {} if neccessary
+ * ------------------------------------------------------------ */
+
+- String *addtofunc(Node *n) {
+- String* str = Getattr(n, "feature:addtofunc");
++ String *pythonappend(Node *n) {
++ String* str = Getattr(n, "feature:pythonappend");
+ char* t = Char(str);
+ if (*t == '{') {
+ Delitem(str ,0);
+ Delitem(str,DOH_END);
+@@ -1657,9 +1982,18 @@
+ mod = Getattr(n,"module");
+ if (mod) {
+ String *modname = Getattr(mod,"name");
+ if (Strcmp(modname,mainmodule) != 0) {
+- importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name"));
++ // check if the module has a package option
++ String* pkg = NULL;
++ Node *options = Getattr(mod, "options");
++ if (options && Getattr(options, "package"))
++ pkg = Getattr(options, "package");
++
++ if (!package || Strcmp(pkg, package) != 0)
++ importname = NewStringf("%s.%s.%s", pkg, modname, Getattr(n,"sym:name"));
++ else
++ importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name"));
+ } else {
+ importname = NewString(Getattr(n,"sym:name"));
+ }
+ Setattr(n,"python:proxy",importname);
+@@ -1731,9 +2065,11 @@
+ Printf(f_shadow, modern ? "(object)" : "(_object)");