class-factory

Python Class Factory to Produce simple Struct-like classes.

While investigating Ruby I came across this to create a simple Struct-like class: Person = Struct.new(:forname, :surname) person1 = Person.new('John', 'Doe') puts person1 #<struct Person forname="John", surname="Doe"> Which raised a few Python questions for me. I have written a [VERY] basic clone of this mechanism in Python: def Str...

Instantiate a inherited class using a static method from a base class.

I have a abstract base class that I have many inherited classes coming off of. What I would like to do is a static member takes in a string, the first class that can parse the string (only one of the inherited classes should be able to) and return a instance of the inherited class. This is what i am currently doing. public static Epl2C...