On Feb 21, 2014, at 6:32 AM, Roy Smith <[email protected]> wrote: > In article <[email protected]>, > Peter Otten <[email protected]> wrote: > > >> [x*x for (x,) in lst] >> >> [paraphrasing...] can be better written as: >> >> [x*x for [x] in items] > > I'm torn between, "Yes, the second form is distinctly easier to read" > and, "If you think the second form is easier to read, you're admitting > you're not really fluent in Python”.
I’ve used the comma form with struct.unpack() frequently: count, = struct.unpack(‘!I’, self.packet) That’s after I don’t use it and end up scratching my head for a while and finally remember that unpack returns a tuple regardless of how many things I unpack from it. It’s just natural if you’re doing lots of single unpacks to think it returns a single value. Either way, I much prefer it to: count = struct.unpack(‘!I’, self.packet)[0] -- https://mail.python.org/mailman/listinfo/python-list
