About 50 results
Open links in new tab
  1. Getting the name of a variable as a string - Stack Overflow

    Aug 25, 2013 · I already read How to get a function name as a string?. How can I do the same for a variable? As opposed to functions, Python variables do not have the __name__ attribute. In other …

  2. python - How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be a local. If a …

  3. syntax - Python integer incrementing with ++ - Stack Overflow

    In Python, you deal with data in an abstract way and seldom increment through indices and such. The closest-in-spirit thing to ++ is the next method of iterators.

  4. variables - What does "if var" mean in python? - Stack Overflow

    In Python, writing if var: has the same effect as writing if bool(var): (where bool is the built-in bool type which also acts as a constructor function for bool objects). If the value is already a bool (valued True …

  5. python - How is `var [:] = []` different from `var = []`? - Stack Overflow

    Nov 6, 2019 · The assignment var = [] binds the name var to the newly created list. The name var may or may not have been previously bound to any other list, and if it has, that list will remain unchanged. …

  6. How can I determine a Python variable's type? - Stack Overflow

    In Python code, this shouldn't make a bit of difference because the interpreter automatically converts to long when a number is too large. If you want to know about the actual data types used in the …

  7. How can I access environment variables in Python?

    How can I get the value of an environment variable in Python?

  8. Behaviour of increment and decrement operators in Python

    Sep 28, 2009 · Python is not C or C++. Different design decisions went into making the language. In particular, Python deliberately does not define assignment operators that can be used in an arbitrary …

  9. python - How do I check if a variable exists? - Stack Overflow

    May 9, 2009 · I want to check if a variable exists. Now I'm doing something like this: try: myVar except NameError: # Do something. Are there other ways without exceptions?

  10. python - How do I pass a variable by reference? - Stack Overflow

    Jun 12, 2009 · Python: Python is “pass-by-object-reference”, of which it is often said: “Object references are passed by value.” (read here). Both the caller and the function refer to the same object, but the …