H
H
Hukyl2020-07-01 19:29:26
Python
Hukyl, 2020-07-01 19:29:26

Why doesn't lambda expression work?

My lambda expression doesn't work and throws a SyntaxError. Already tried a lot of things, does not help

class Example:
    def __init__(self):
        self.conn = sqlite3.connect("Example.sqlite3")
        self.cursor = self.conn.cursor()
        self._check_password = lambda word: raise ValueError("wrong password") if word != self.cursor.execute("Select password from members where login = ?", (user_login, )).fetchone()[0] 

start = Example()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-07-01
@Hukyl

First, if you assign a lambda to a variable, then you are using it for other purposes. Second, lambdas should not create side effects. Thirdly, operators cannot be used in lambdas.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question