About 228,000 results
Open links in new tab
  1. Python, creating objects - Stack Overflow

    Feb 26, 2013 · The so called "factory method" pattern, the one where you use a method or a function to create object of some kind instead of creating them directly in the code, is a useful …

  2. 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: obj = object () obj.somefield = "somevalue" AttributeError: 'object' object has no …

  3. How to create a new unknown or dynamic/expando object in Python

    Dec 24, 2012 · In python how can we create a new object without having a predefined Class and later dynamically add properties to it ? example: dynamic_object = Dynamic() …

  4. How to create a new instance from a class object in Python

    May 8, 2011 · 113 I need to dynamically create an instance of a class in Python. Basically I am using the load_module and inspect module to import and load the class into a class object, but …

  5. python - Create new object (class instance) from object method

    I want to be able to create a new instance of an object by calling a method on an already instantiated object. For example, I have the object: organism = Organism() I want to be able to …

  6. python - Create an object without calling a class - Stack Overflow

    Jan 21, 2012 · 33 In Python you can add members dynamically to an object, but (1) the name must already exist (it must have been assigned) and (2) it must be bound to an instance of …

  7. How to create inline objects with properties? - Stack Overflow

    It is easy in Python to declare a class with an __init__() function that can set up the instance for you, with optional arguments. If you don't specify the arguments you get a blank instance, and …

  8. python - How to dynamically build a JSON object? - Stack Overflow

    I am new to Python and I am playing with JSON data. I would like to dynamically build a JSON object by adding some key-value to an existing JSON object. I tried the following but I get …

  9. How can I create a copy of an object in Python? - Stack Overflow

    Jan 25, 2011 · 173 How can I create a copy of an object in Python? So, if I change values of the fields of the new object, the old object should not be affected by that. You mean a mutable …

  10. python - Django Model () vs Model.objects.create () - Stack Overflow

    I don't see that as contradictory. Generally in python, You instantiate objects by putting brackets after the Objects name not by a create method