Skip to content

calling methods with keyword parameters  #6

Open
@heilgeirr

Description

@heilgeirr

Example: JDI/web/selenium/elements/base/element.py Element.init method

Instead of branching on condition if by_locator param is None,

class Element(BaseElement):

def __init__(self, by_locator=None, web_element=None):
    self.parent = None
    if by_locator is not None:
        super(Element, self).__init__(by_locator=by_locator)
    elif web_element is not None:
        super(Element, self).__init__()
        self.avatar.set_web_element(web_element)
    else:
        super(Element, self).__init__()

You can simply pass by_locator parameter (including None value) to super().init
(There are no overloaded methods (methods with different signatures) in python)

`
def init(self, by_locator=None, web_element=None):

super(Element, self).__init__(by_locator=by_locator)

if web_element is not None:

    self.avatar.set_web_element(web_element)

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions