borozu
borozu

Reputation: 9

Python nested functions

Absolutely newbie in Python. Statement is satisfied as user exist in DB so program prints "DETAILS CORRECT" but also I would like it to jump to next window (made in PyQt5) by going through next function. Is that correct? def function2

    else:
        cur = conn.cursor()
        query = 'SELECT customer_password FROM customers_table WHERE customer_login =\'' + customerlogin + "\'"
        cur.execute(query)
        result_pass = cur.fetchone()[0]
        if result_pass == customerpassword:
            def function2():   
        self.errorlabel.setText("DETAILS CORRECT")
        else:
            self.errorlabel.setText("PLEASE CHECK DATA OR REGISTER")

Upvotes: 0

Views: 102

Answers (1)

Mohammad
Mohammad

Reputation: 3396

You need to call the function not define it, you define it somewhere else:

def func2():
    ...

...

if result_pass == customerpassword:
    self.errorlabel.setText("DETAILS CORRECT")
    func2()     
else:
    self.errorlabel.setText("PLEASE CHECK DATA OR REGISTER")

Upvotes: 2

Related Questions