About 2,080,000 results
Open links in new tab
  1. python - Getting the name of a variable as a string - Stack Overflow

    Aug 25, 2013 · Variables don't "have names"; "variable" means the same thing as "name" in Python. Presumably you meant value (as in, the actual object that is being named); but values …

  2. How To Print A Variable's Name In Python - GeeksforGeeks

    Dec 10, 2025 · Python does not provide a built-in way to retrieve a variable’s name directly, but with some clever approaches, it is possible to identify a variable by its reference in the code.

  3. Unveiling the Mystery: How to Get the Name of a Variable in Python

    Apr 13, 2025 · Understanding these methods can be extremely useful in debugging, logging, and more complex programming tasks where variable names carry important semantic information. …

  4. Python - Variable Names - W3Schools

    A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)

  5. python: inserting a variable value into a variable name

    Feb 14, 2010 · I would like to insert the value of a variable into the name of another variable in python. In a shell script this would be something like: for n in `more list` do var_$n = …

  6. Convert String into Variable Name in Python - GeeksforGeeks

    Sep 25, 2023 · There may be situations where you want to convert a string into a variable name dynamically. In this article, we'll explore how to convert a string into a variable name in Python …

  7. Get Variable Name As String In Python - GeeksforGeeks

    Jul 1, 2025 · Getting a variable name as a string in Python means finding the label that points to a specific value. For example, if x = "Python", we can loop through globals () or locals () and …

  8. Python: Getting Variable Names - CodeRivers

    Apr 13, 2025 · However, Python doesn't provide a straightforward built - in way to directly get the variable name in all cases. This blog post will explore different techniques to achieve this, …

  9. python - Using a string variable as a variable name - Stack Overflow

    Jul 19, 2012 · I have a variable with a string assigned to it and I want to define a new variable based on that string. foo = "bar" foo = "something else" # What I actually want is: bar...

  10. What is the naming convention in Python for variables and …

    Variable names follow the same convention as function names. mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards …