lampahome wrote:

> Above is I thought to make code clear, and this pattern is called simple
> factory?

This is a factory function:

> def get_class(obj):
>     if obj == 'A1' or obj == 'A2':
>         return A(obj)
>      else:
>         return B(obj)

The rest is just cruft ;)
> 
> *Is there better design pattern for me?*

If A does B to C, is that a crime?

Your problem description suffers from overgeneralisation.

Generally speaking you get better solutions when you ask yourself
    "How can I solve this problem efficiently?"
rather than
    "What fancy design patterns can I use while solving this problem?"

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to