Questions tagged [dynamic-class-creation]

Some Object Oriented programming languages allow creating new classes (types) in run-time (as compared to classes defined in the source code and created in compilation time)

Some examples of creating types in run-time:
C#
C++
Java
Python

78 questions
1
vote
2 answers

What is the difference between class syntax and type()?

I am well aware of fact that classes can be declared dynamically in python using type and have used it here and there. But I am still unclear what are the differences between these two functions. def class_factory(): def init(self, attr): …
Nafees Anwar
  • 6,324
  • 2
  • 23
  • 42
1
vote
2 answers

How to create a class from a Dictionary in C#?

I have written a method which creates a Dictionary. I need to convert this dictionary to a class. Example of Dictionary Dictionary myDictionary = new Dictionary { { "ID1", 12 }, { "ID2",…
Ehsan Aliverdi
  • 143
  • 1
  • 1
  • 6
1
vote
0 answers

Dynamically create a class that implements arbitrary interfaces

I'm creating a PHP library to extract schema.org structured data out of web pages. Schema.org features a multiple inheritance hierarchy that I can only achieve through PHP interfaces: interface LocalBusiness extends Organization, Place { } In…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
1
vote
1 answer

Python set attributes during object creation in __new__

When using __new__ to customize the creation of a metaclass, we can pass attributes to the type().__new__ method which will be set on the object before it is returned, e.g. class Foo(type): def __new__(cls, name, bases, attrs): …
aaa90210
  • 11,295
  • 13
  • 51
  • 88
1
vote
4 answers

php dynamic class inheritance

I know I can generate a class at runtime by executing $obj = (object)array('foo' => 'bar');+ this way I can use echo $obj->foo; //bar What if want to make $obj inherits from an existing class? What I wanna achive: I'm forking paris project on…
balanza
  • 1,059
  • 1
  • 12
  • 34
1
vote
3 answers

AS3 - Parametrized Factory method using actual class name

Rather than use a hard-coded switch statement where you pass it the string name of a class and it then instantiates the appropriate class, I'd like to pass the actual name of the class to my factory method and have it dynamically create an instance…
Tom Auger
  • 19,421
  • 22
  • 81
  • 104
1
vote
3 answers

What's the term (if any) for frameworks that support dynamic class creation?

Sorry about the vocabulary question, but I'm writing my master thesis and it's a pain to repeat "frameworks that support dynamic class creation" again and again. Is there a term for that? Some clarification: I mean that you can create a class at…
Alix
  • 927
  • 7
  • 21
1
vote
1 answer

python use different parent class for child class

Using python and django we are creating a framework to run a number of scientific models. Python runs the models, and django is used to keep track of status and to create output to webpages. In operational mode this works fine, as the entire…
Bart P.
  • 849
  • 1
  • 8
  • 11
1
vote
1 answer

How to dynamically create classes inside a module-level initialize() method in Python

I'm writing a library to talk to a database using SQLAlchemy. I really like SQLAlchemy's autoload_with=engine feature, which can be passed to the Table constructor to grab all of the table's columns without the programmer having to define them…
Rob Crowell
  • 1,447
  • 3
  • 15
  • 25
1
vote
2 answers

call super in subclass created by type

Update: made some progress and simplified the example, although I'm currently stumped by the latest error. I have no idea why the super().__init__ method is unbound. import types class VeryImportantSuperClass(object): def __init__(self, anArg,…
elhefe
  • 3,404
  • 3
  • 31
  • 45
1
vote
2 answers

Invoke dynamic object's method

How can I invoke/call an object's method from another object method when both objects are created dynamically? The situation is as follows: I have two objects created dynamically each object correspond to a different class objA Method1A() objB …
armadillo.mx
  • 934
  • 1
  • 11
  • 17
0
votes
2 answers

Can I dynamically/on the fly create a class from an interface, and will nHibernate support this practice?

I’ve done some Googling but I have yet to find a solution, or even a definitive answer to my problem. The problem is simple. I want to dynamically create a table per instance of a dynamically named/created object. Each table would then contain…
J R
  • 335
  • 4
  • 8
0
votes
1 answer

Create Dynamic class at runtime

can any body have idea for create dynamic class at run time.i have one dictionary which is contains datatable's all columns with it's datatype my plan is to create a dynamic class base on dictionary. means datatable's column name is…
0
votes
1 answer

Giving method name instead of concrete class name in Structure map

I have a class ScreenParameter (implement IScreenParameter) that stores all form values in windows form. This class is initiated when user populate all the fields and click the button. The class in Bussiness Layer waits IScreenParameter in its…
londondev
  • 231
  • 2
  • 13
0
votes
1 answer