Generating python code from class diagram

There are some issues with the class diagram and also with the generated code when converting the diagrams into code.

  • when I add a Constructor to the class from the context menu, the class gets a new Operation that has the same name as the class itself.
    • while that might be a constructor in Java or C++, it isn’t in Python, where the constructor has the name __init__
    • so now I have a surplus operation (method) named eg. MyClass, and I still have no valid constructors in the generated code
    • as soon as I start adding attributes, the generated code gets the __init__ constructor added to it but it does not show anywhere in the class diagram, and as such, its code cannot be modified either. It only consists of setting the attributes to None, and that’s it.
  • also, there are some minor issues with docstrings generated from Description text
    • PEP 257 (PEP 257 -- Docstring Conventions | describes some specifications and conventions for eg. multi-line docstrings that are neither followed by the generated code nor can be hacked into by playing around with the text
      • eg. it says that the multi-line docstring should use double quotes when triple-quoting. So far, so good but it also says that you should place the closing quotes on a line by themselves. However, the generated code does not have it so, the closing triple-quote is at the end of the last line. And it’s not possible to trick VP into doing so by adding an empty line at the end of the Description, because it’s removed as soon as I apply the changes to the Description.

Is there any way to change these behaviors?

Hi Gemisigo,

Thank you for your post. Our engineers will review your case shortly. When I have got their reply I will post here.

Best regards,
Jick Yeung