list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

E9213 Python Module Name Clash

A class or namespace is named like a standard Python module

Each class becomes a Python module named after its namespace and class, and Python resolves the first part of that name before anything else. That part must not be the name of a standard library module (such as datetime, json, os, queue or email). A class without a namespace named like one would hide the standard module from the whole program, generated code included, or could not be imported when the standard module is built into the interpreter or already loaded. A namespace named like one could not be imported: Python finds the standard module before the generated directory. The Python generator reports the class or interface and does not generate it.

Rename the class, or use a namespace whose first part is not a standard module name (app.sys is fine).

Example

// A class without a namespace named like a Python standard
// module that generated code imports hides that module: E9213
generate Python;
class datetime {
  Integer day;
}

      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// In a namespace the class gets its own package, so the
// standard module stays reachable
generate Python;
namespace planner;
class datetime {
  Integer day;
}

      

Load the above code into UmpleOnline