About 50 results
Open links in new tab
  1. how to dynamically create an instance of a class in python?

    Create a class instance from a full path to a class constructor :param class_str: module name plus '.' plus class name and optional parens with arguments for the class's

  2. python - How can I create an object and add attributes to it? - Stack ...

    May 13, 2010 · I want to create a dynamic object in Python and then add attributes to it. This didn't work:

  3. python - Creating class instance properties from a dictionary? - Stack ...

    The above code snippet creates a class of which instance attributes are based on a given dictionary. SilentGhost's code creates a class whose class attributes are based on a given dictionary. …

  4. How to create a Python class - Stack Overflow

    Mar 12, 2016 · What I need help doing is creating a class in Python that defines penny as an object, so later on I can go back in and change it to nickel, dime, quarter, etc, I have the basic idea of how to …

  5. python - How to add property to a class dynamically ... - Stack Overflow

    If you want to define a property on a single instance, you can create a class at runtime and modify __class__.

  6. How to pass an input argument when creating an instance of a class?

    8 Remove the name param from the class declaration. The __init__ method is used to pass arguments to a class at creation.

  7. Create a python class definition from a serialized JSON object?

    Feb 18, 2024 · 2 What I'm trying to do is to create Python class definitions in code by reading a JSON file. I don't want to have the class pre-written in Python and then load it with the JSON data. I want to …

  8. How do you create an incremental ID in a Python Class

    What if you want to make a class FooBar(BarFoo) and have it use a separate counter? Do you need to redefine id_iter in each child class?

  9. python - Class (static) variables and methods - Stack Overflow

    Sep 16, 2008 · See what the Python tutorial has to say on the subject of classes and class objects. @Steve Johnson has already answered regarding static methods, also documented under "Built-in …

  10. Convert string to Python class object? - Stack Overflow

    Jul 24, 2009 · Given a string as user input to a Python function, I'd like to get a class object out of it if there's a class with that name in the currently defined namespace. Essentially, I want the implementat...