Just took a look in the perl newsgroup....

Asun Friere afriere at yahoo.co.uk
Mon May 19 21:30:54 EDT 2003


Graham Nicholls <graham at rockcons.co.uk> wrote in message news:<1H6ya.6977$573.2647 at news-binary.blueyonder.co.uk>...
> And remembered why I decided I must learn Python :-)
> I clearly need to learn "the Python Way", which _is_ quite different, and
> has its good and bad points (stamps foot.  I _want_ a case statement).

I think part of the problem here is that Python is trying to be too
many things perhaps.  While a case statement would certainly be useful
for simple scripting, Python is also an OO language.  The problem with
including a case statement is that people might actually use it!  The
'case' statement is to OO what 'goto' is to structural programming. 
As Jay O'Connor pointed out in the other thread, in an OO context
(which _simple_ scripts are not), relying on polymorphism (via some
kind of dispatch mechanism), is preferable to employing a case-like
construct.  Associated with this is the stricture against type
testing.

So what I'm saying is that 'the Python Way' might vary according to
how it is being used.  Nonetheless the basic OOness of the language
argues against the inclusion of a 'case' construct.  In any case, as
has also been pointed out, you can used dictionaries to emulate case
in contexts where a dispatch mechanism would be either overkill or
simply not possible.




More information about the Python-list mailing list