do design patterns still apply with Python?

Bo Yang struggleyb at
Sat Mar 4 16:17:51 CET 2006

Paul Novak 写道:
> A lot of the complexity of design patterns in Java falls away in 
> Python, mainly because of the flexibility you get with dynamic typing.
I agree with this very much !
In java or C++ or all such static typing and compiled languages , the 
type is fixed on
in the compile phrase , so for the flexible at the runtime , we often 
need to program to
interface . For example ,
we do in java :

implement I{...}
class A implement I{...}
class B implement I{...}

oprate(I var) // we can pass A's instance or B's instance here

and in C++ :

class Abstract{...}
class A : Abstract{...}
class B : Abstract{...}

oprate(Abstract var) // pass the A's instance or B's instance here

But in python , type is dynamic , and name is bind at runtime , so we 
can pass any variable as we want ! This feather make python not need for 
redundant class inherits
and interfaces which are the core of the GoF's design patterns I think !

> For a Pythonic Perspective on Patterns, "Python Programming Patterns" 
> by Thomas W. Christopher is definitely worth tracking down. It looks 
> like it is out of print, but you can find used copies on Amazon.
> Regards,
> Paul.
>         This sounds like an article crying out to be written,
>         "(Learning) Design Patterns with Python".
>         Has it been written already?
>         Cheers,
>         Terry
>     Bruce Eckel began writing "Thinking In Python" it was last updated
>     in 2001.

More information about the Python-list mailing list