About 205,000 results
Open links in new tab
  1. What is the best way of implementing a singleton in Python?

    Jun 10, 2020 · This process is the same as Python asking a class what to do by calling __getattr__ when you reference one of its attributes by doing myclass.attribute. A metaclass …

  2. How can I dynamically create derived classes from a base class

    The general answer on how to "dynamically create derived classes from a base class" in Python is a simple call to type passing the new class name, a tuple with the baseclass (es) and the …

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

  4. python - How to create a list of objects? - Stack Overflow

    Aug 15, 2020 · How do I go about creating a list of objects (class instances) in Python? Or is this a result of bad design? I need this cause I have different objects and I need to handle them at …

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

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

  6. python - Creating class instance properties from a dictionary?

    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 …

  7. Python, creating objects - Stack Overflow

    Feb 26, 2013 · when you create an object using predefine class, at first you want to create a variable for storing that object. Then you can create object and store variable that you created.

  8. Generics/templates in python? - Stack Overflow

    Oct 13, 2014 · Each time you create a generic type, it will create a new type. Thus, multiple classes inheriting List( str ) as a parent would be inheriting from two separate classes. To …

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

  10. How to pass an input argument when creating an instance of a …

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