[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Understanding exceptions



On Saturday 21 February 2004 23:00, Florent Rougon wrote:
> Hi,
>
> Tilo Schwarz <list@tilo-schwarz.de> wrote:
> > Hi together,
>
> [...]
>
> > here). For me, KISS would be more like that:
>
> [ piece of code ]
>
> > But, as always, it's a matter of taste...
>
> I agree that your way of coding this particular algorithm is relatively
> elegant. I said in another message that I would have done this way if
> there would have been a bit more different message types. It's a fuzzy
> threshold problem as when to deploy a generic machinery or not.

Agreed...

> While your way is nice, many people will still prefer the one I first
> proposed because this instruction:
>
>         appli.update(dict(zip(msg["fieldnames"],
>                               fieldvalues)))
>
> is relatively complicated to understand (you probably know that Guido
> has thought many times about removing built-in some functions that lead
> to functional-style coding such as zip, map or reduce---don't remember

yes, but it wasn't "zip" I guess, just got introduced in Python 2.0

> which ones, though; this because he thinks they often decrease the
> readability of the code and thus should be replaced by explicit loops).

I thought, dict(zip(listOfKeys, listOfValues)) is the common idiom to 
initialize a dict from a keylist and valuelist. But, as you said, you can 
write above of course as

for name, value in zip(msg["fieldnames"], fieldvalues):
	appli[name] = value

> In my own projects, I generally write things the way you proposed,
> because I like the elegance of the generic "formula", so to speak. In
> that particular project, I was time-constrained (I said it was
> closed-source code!) and couldn't always code the way I would have in a
> free software project. But the end result was still easily readable and

... not all my code is nice and beautiful ;-)

Regards,

	Tilo



Reply to: