How to get the caller class name inside a function of another class in python?

Well, after some digging at the prompt, here’s what I get: stack = inspect.stack() the_class = stack[1][0].f_locals[“self”].__class__.__name__ the_method = stack[1][0].f_code.co_name print(“I was called by {}.{}()”.format(the_class, the_method)) # => I was called by A.a() When invoked: ➤ python test.py A.a() B.b() I was called by A.a() given the file test.py: import inspect class A: def a(self): … Read more

Drawing Sequence Diagrams [closed]

PlantUML. http://plantuml.sourceforge.net/sequence.html PlantUML is used to draw UML diagram, using a simple and human readable text description. The generated images can then be used without any reference to the GPL/LGPL/ASL/EPL/MIT license. It is not even necessary to stipulate that they have been generated with PlantUML, although this will be appreciate by PlantUML team. In my … Read more

How to correct PlantUML Line Path

There are some tricks that you can try, listed below. The layouting itself is performed by GraphViz (dot layouting iirc), and GraphViz simply does this sometimes. Graph layouting is a NP-complete problem, so algorithms usually take harsh shortcuts. Typical workarounds that I’ve seen or used include: adding hidden lines a -[hidden]- b extending the length … Read more

tech