switch

Carl Banks pavlovevidence at gmail.com
Wed Dec 9 03:08:39 EST 2009


On Dec 8, 9:36 pm, Asun Friere <afri... at yahoo.co.uk> wrote:
> This code is probably symptomatic of poor design. (Not to mention that
> your condition tests).  For which reason python has no 'case'
> statement and why no decent OO language should.
>
> It is a principle of OO design that "an object should know what to do
> itself."  Rather running an object though a series of tests, it is
> better to send the object a message, relying on polymorphism or duck-
> typing, and deal with any exceptions thrown.

What if the object is a string you just read from a file?

How do you dispatch using polymorphism in that case?


Carl Banks



More information about the Python-list mailing list