On Fri, Oct 26, 2012 at 5:06 PM, Paul Rubin <no.email@nospam.invalid> wrote: > Dan Loewenherz <dloewenh...@gmail.com> writes: >> In this case, profile_id is "None" when the loop breaks. It would be >> much more straightforward (and more Pythonic, IMO), to write: >> >> client = StrictRedis() >> while client.spop("profile_ids") as profile_id: >> print profile_id > > That is pretty loose, in my opinion. If the loop is supposed to return > a string until breaking on None, the break test should explicitly check > for None rather than rely on an implicit bool conversion that will also > test as false on an empty string.
while (client.spop("profile_ids") as profile_id) is not None: print profile_id Why is everyone skirting around C-style assignment expressions as though they're simultaneously anathema and the goal? :) But seriously, this new syntax would probably enhance Python somewhat, but you're going to end up with odd edge cases where it's just as almost-there as current syntax is for what this will solve. Is it worth doing half the job? ChrisA -- http://mail.python.org/mailman/listinfo/python-list