About 50 results
Open links in new tab
  1. python - How to assign a variable in an IF condition, and then return ...

    Apr 27, 2019 · 189 Starting Python 3.8, and the introduction of assignment expressions (PEP 572) (:= operator), it's now possible to capture the condition value (isBig(y)) as a variable (x) in order to re …

  2. python - One line if-condition-assignment - Stack Overflow

    Oct 24, 2011 · One line if-condition-assignment Asked 14 years, 4 months ago Modified 4 months ago Viewed 537k times

  3. Variable assignment and modification (in python) [duplicate]

    Variable assignment and modification (in python) [duplicate] Asked 14 years, 7 months ago Modified 13 years, 1 month ago Viewed 49k times

  4. What happens when you assign the value of one variable to another ...

    Jul 12, 2017 · A Python variable's name is a key in the global (or local) namespace, which is effectively a dictionary. The underlying value is some object in memory. Assignment gives a name to that …

  5. python - Why do I get a "referenced before assignment" error when ...

    See Python reference. You should declare variable without global and then inside the function when you want to access global variable you declare it global yourvar.

  6. python - How can I fix "UnboundLocalError: local variable referenced ...

    UnboundLocalError: local variable 'f' referenced before assignment Python sees the f is used as a local variable in [f for f in [1, 2, 3]], and decides that it is also a local variable in f(3).

  7. coding style - Assignment with "or" in python - Stack Overflow

    Jan 6, 2012 · Is it considered bad style to assign values to variables like this? x = "foobar" or None y = some_variable or None In the above example, x gets the value 'foobar'.

  8. Assignment inside lambda expression in Python - Stack Overflow

    Jun 8, 2011 · The assignment expression operator := added in Python 3.8 supports assignment inside of lambda expressions. This operator can only appear within a parenthesized (...), bracketed [...], or …

  9. python - What are assignment expressions (using the "walrus" or ...

    117 Since Python 3.8, code can use the so-called "walrus" operator (:=), documented in PEP 572, for assignment expressions. This seems like a really substantial new feature, since it allows this form of …

  10. How does Python's comma operator work during assignment?

    All the expressions to the right of the assignment operator are evaluated before any of the assignments are made. From the Python tutorial: First steps towards programming: The first line contains a …