About 305,000 results
Open links in new tab
  1. How do I define a name in python? - Stack Overflow

    Feb 21, 2022 · Now, If you really want to know how to define an object in oops in Python, here is the way to do it: First instead of creating a class inside a class, you should just create one …

  2. Python NameError: name is not defined - Stack Overflow

    Feb 11, 2013 · Note that sometimes you will want to use the class type name inside its own definition, for example when using Python Typing module, e.g. class Tree: def __init__(self, …

  3. python - Getting the name of a variable as a string - Stack Overflow

    Aug 25, 2013 · Python uses names in the source code to refer to (i.e., give a name to) values. (In many languages, a variable is more like a name for a specific location in memory where the …

  4. python - How do you create different variable names while in a …

    I would personally define a list for your (dynamic) variables to be held and then append to it within a for loop. Then use a separate for loop to view each entry or even execute other operations. …

  5. Convert string to variable name in python - Stack Overflow

    This is the best way, I know of to create dynamic variables in python. my_dict = {} x = "Buffalo" my_dict[x] = 4 I found a similar, but not the same question here Creating dynamically named …

  6. python - What does if __name__ == "__main__": do? - Stack Overflow

    Jan 7, 2009 · When you run Python interactively the local __name__ variable is assigned a value of __main__. Likewise, when you execute a Python module from the command line, rather …

  7. python - Calling a function of a module by using its name (a string ...

    Jun 4, 2022 · Given a string, with a complete python path to a function, this is how I went about getting the result of said function: import importlib function_string = …

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

    PEP 8 is a guideline, not a law. It is an option on top of Python, not part of the official language. If everybody uses the same style, this would be preferred in a bigger company. All my Python …

  9. python - How do I fix this "Name is not Defined"? - Stack Overflow

    Nov 17, 2014 · Your specific issue of NameError: name 'guess' is not defined is because guess is defined in your main function, but the while loop that it is failing on is outside of that function. …

  10. python - How can you dynamically create variables? - Stack Overflow

    Sep 18, 2021 · $ python b.py name 'B' is not defined __main__ <module '__main__' from 'b.py'> B: 1 But this approach only works in a single module script, because the __main__ it import …

Refresh