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

User Manual    [Previous]   [Next]   

E9214 Python Self Parameter

A method or event has a parameter named self

Generated Python methods name the object they are called on self, so a parameter cannot also be named self. The Python generator reports this error at the method (for an event, at its class) and does not write a Python file for the class. Rename the parameter.

Example

// Python reserves self for the object a method is called on
generate Python;
class Shape {
  Double scale(Double self) Python { return self * 2 }
}

      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// Any other parameter name works
generate Python;
class Shape {
  Double scale(Double factor) Python { return factor * 2 }
}

      

Load the above code into UmpleOnline