Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling methods with keyword parameters #6

Open
heilgeirr opened this issue Jul 27, 2018 · 0 comments
Open

calling methods with keyword parameters #6

heilgeirr opened this issue Jul 27, 2018 · 0 comments

Comments

@heilgeirr
Copy link
Collaborator

heilgeirr commented Jul 27, 2018

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)

`

ZoiaOchikova pushed a commit that referenced this issue Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant