Skip to content

Usage of super in ptyhandler.py #5

@giselher

Description

@giselher

As said in the meeting the code is written with old style classe in mind and super should be only be used in new style classes.

Link to the code line: https://github.com/rainerf/ricodebug/blob/master/src/helpers/ptyhandler.py#L33

Use cases for super from the python 2.7 Documentation (http://docs.python.org/library/functions.html?highlight=super#super)

There are two typical use cases for super. In a class hierarchy with single inheritance, super can be used to refer to parent classes without naming them explicitly, thus making the code more maintainable. This use closely parallels the use of super in other programming languages.

The second use case is to support cooperative multiple inheritance in a dynamic execution environment. This use case is unique to Python and is not found in statically compiled languages or languages that only support single inheritance. This makes it possible to implement “diamond diagrams” where multiple base classes implement the same method. Good design dictates that this method have the same calling signature in every case (because the order of calls is determined at runtime, because that order adapts to changes in the class hierarchy, and because that order can include sibling classes hat are unknown prior to runtime).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions