From: Michael D. <md...@st...> - 2008-10-07 16:54:18
|
Sorry. I didn't read carefully enough. That's right -- the "if converter: break" was replaced with "return converter". You're right. This is fine. Mike John Hunter wrote: > On Tue, Oct 7, 2008 at 11:26 AM, Michael Droettboom <md...@st...> wrote: > >> This isn't quite what I was suggesting (and seems to be equivalent to >> the code as before). In the common case where there are no units in the >> data, this will still traverse the entire list. >> >> I think replacing the whole loop with: >> >> converter = self.get_converter(iter(x).next()) >> >> would be even better. (Since lists of data should not be heterogeneous >> anyway...) >> > > Hmm, I don't see how it would traverse the entire list > > for thisx in x: > converter = self.get_converter( thisx ) > return converter > > since it will return after the first element in the loop. I have no > problem with the iter approach, but am not seeing what the problem is > with this usage. > > JDH > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |