Some more notes

Cliff Wells clifford.wells at comcast.net
Thu Oct 21 21:43:32 EDT 2004


On Thu, 2004-10-21 at 18:07 -0700, Jeff Shannon wrote:
> bearophile wrote:
> 
> >I think some things are better in Delphi/Pascal 
> >
> 
> They may well be better _in_ Delphi/Pascal.  That doesn't mean that 
> adding them into Python will make Python a better language.  (I love 
> garlic.  I love chocolate.  I do not want to eat chocolate-covered 
> garlic cloves, nor garlic-flavored chocolate bars.)

Well, that's a matter of personal taste.  Garlic is good on
*everything*.

> >2) Adding "case var of:" can be useful.

> Not sure exactly what this is, but if you're referring to a case/switch 
> construct: using a dict of functions is (IMO) a better and cleaner way 
> of implementing the same idea.

For many things this is true (and I use function lookup tables
frequently).  However it doesn't as conveniently cover all use cases
that switch/case does (as it requires a function definition for each
item).  While it's also true that if/elif/else can be used instead for
these other cases, I personally find switch/case far cleaner looking
(when there are more than five or six conditions to test).

Also, I'd be reluctant to claim that the dictionary lookup is cleaner
(it looks more cluttered to my eye), but rather, more flexible (items
can be dynamically added to the list).

Regards,
Cliff

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list