About 282,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 - What does if __name__ == "__main__": do? - Stack Overflow

    Jan 7, 2009 · Likewise, when you execute a Python module from the command line, rather than importing it into another module, its __name__ attribute is assigned a value of __main__, …

  3. python - How to avoid "NameError: name is not defined" when …

    The solution to this problem is to invoke your classes and functions after you define them. Python does not have any way to forward declare classes or methods so the only option is to put the …

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

    It's simply pointless to create variable variable names. Why? They are unnecessary: You can store everything in lists, dictionarys and so on They are hard to create: You have to use exec …

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

    buffalo=4 not only this example, I want to convert any input string to some variable name. How should I do that (in python)?

  6. Python dynamic function creation with custom names

    I need to create dynamic functions in Python (Python2.7) with custom names at runtime. The body of each function also needs to be constructed at runtime but it is (almost) the same for all …

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

    Aug 25, 2013 · In Python, the def and class keywords will bind a specific name to the object they define (function or class). Similarly, modules are given a name by virtue of being called …

  8. How can we force naming of parameters when calling a function?

    How can we force people to name certain parameters - not just a coding standard, but ideally a flag or pydev plugin? So that in the above 4 examples, only the last would pass the check as …

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

    The exception is in Python 2.x when you use exec inside a function without specifying a local namespace for the exec. I'm not sure offhand where this is documented: it isn't part of the …

  10. python - How do I forward-declare a function to avoid …

    In python the statement globals()[function_name]() is the same as foo() if function_name = 'foo' for the reasons discussed above, since python must lookup each function before calling it. If one …