Implementation
Python

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
auto fact(T, A...)(A a)
if (is(T==class) && is(T: Parent))
{
    return new T(a);
}
type ParentFactory func(string) Parent

var fact ParentFactory = func(str string) Parent {
	return Parent{
		name: str,
	}
}
def fact(klass, str)
  klass.new(str) if klass.is_a?(Parent)
end
type Parent = class
  constructor create(const str: string);
end;

type ClassOfParent = class of Parent;

function fact(ClassType: ClassOfParent; const str: string): Parent;
begin
  result := ClassType.Create(str);
end;