bob gailer wrote:


2) "looks bad" and "is ugly" are emotional responses. What are you feeling and wanting when you say those things?

It's hard for me to qualify really but my general idea of list comprehensions is that they transform and filter lists creating other lists.

For instance, I'd call this
if key in foo:
  return foo[key]
else:
  return 'unknown'

'ugly' when compared to

return foo.get(key,'unknown')

I guess I'm looking for the idiomatic way of performing such an operation. My gut feel tells me that the zeroth element of a list comprehension is not the right way to go but I wanted confirmation/rebuttal.

Peace.

--
~noufal
http://nibrahim.net.in/
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to