About 258,000 results
Open links in new tab
  1. python - How can you dynamically create variables? - Stack Overflow

    I want to create variables dynamically in Python. Does anyone have any creative means of doing this?

  2. python - Convert dictionary entries into variables - Stack Overflow

    14 Consider the "Bunch" solution in Python: load variables in a dict into namespace. Your variables end up as part of a new object, not locals, but you can treat them as variables …

  3. python - How do I create variable variables? - Stack Overflow

    I know that some other languages, such as PHP, support a concept of "variable variable names" - that is, the contents of a string can be used as part of a variable name. I heard …

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

    27 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. How to set environment variables in Python? - Stack Overflow

    I need to set some environment variables in the Python script and I want all the other scripts that are called from Python to see the environment variables' set. If I do, …

  6. correct way to define class variables in Python - Stack Overflow

    I noticed that in Python, people initialize their class attributes in two different ways. The first way is like this: class MyClass: __element1 = 123 __element2 = "this is Africa" ...

  7. What is the Python equivalent of static variables inside a function?

    Nov 11, 2008 · In the example below (python 3.5 or greater to use the "f"), the counter variable is defined outside of the function. Defining it as global in the function signifies that the "global" …

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

  9. Creating dummy variables in pandas for python - Stack Overflow

    I'm trying to create a series of dummy variables from a categorical variable using pandas in python. I've come across the get_dummies function, but whenever I try to ...

  10. dictionary - Python variables as keys to dict - Stack Overflow

    Is there an easier way to do this in Python (2.7)?: Note: This isn't anything fancy, like putting all local variables into a dictionary. Just the ones I specify in a list. apple = 1 banana = 'f' c...