About 273,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. 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 …

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

    $ 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 will always …

  7. 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 …

  8. What does -> mean in Python function definitions? - Stack Overflow

    Jan 17, 2013 · funcdef: 'def' NAME parameters ['->' test] ':' suite The optional 'arrow' block was absent in Python 2 and I couldn't find any information regarding its meaning in Python 3. It …

  9. python - Getting the class name of an instance - Stack Overflow

    Jun 13, 2022 · @EduardLuca Double underscores at the start only are similar to a single underscore at the start, but even more "private" (look up "python name mangling"). Double …

  10. 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. …