Logo

Programming-Idioms

History of Idiom 73 > diff from v7 to v8

Edit summary for version 8 by :

Version 7

2015-08-21, 17:12:34

Version 8

2015-08-22, 10:19:33

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Idiom #73 Create a factory

Create a factory named pFact for any sub class of Parent and taking exactly one string str as constructor parameter.

Code
def pFact(a_class, str):
    if issubclass(Parent, a_class):
        return parent(str)