For code completion with Scintilla.Net i need the list of keywords that are valid in an expression. You can get all keywords via the "keyword" module, but for example "raise" and "print" cannot be used in lambda expressions. How can i get the reduced keyword list?
keyword.kwlist yields
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Which ones can be used in an expression?
You're asking the wrong question here. Whether or not a lambda expression can use keywords has no bearing on what is actually valid.
https://docs.python.org/2.7/reference/expressions.html#lambda
All that matters is that the body of a lambda is an expression. Or in other words, something that can be evaluated to a value. That means it cannot contain statements.
So figure out what combination of keywords can be used to form an expression and you'll have your answer.
The documentation also mentions another block of code that is similar:
Put another way, the body of a lambda has to be something that could be placed in a return statement... an expression.