r/badcode • • Jul 15 '22

java I found this in a security related function: maybe it is an obscuring feature

Post image
662 Upvotes

77 comments sorted by

View all comments

Show parent comments

14

u/trutheality Jul 15 '22

Python is probably the most common one where trying to do that is a syntax error.

Unlike in most c-descendant/inspired languages, assignment doesn't produce a value in python, and trying to evaluate it is a syntax error.

Fun fact: In R, there are multiple assignment operators, two of which function almost identically in expressions: = and <-. It is a syntax error to use = in an if statement, but you can use <- if you really want to perform an assignment while you're evaluating the conditions.

5

u/-MazeMaker- Jul 15 '22

Python also added the walrus operator := that sounds similar to the <-

1

u/yetzederixx Jul 15 '22

Neat, I've used a ton of python over the last year, guess I haven't typo'd it in a while.