[Python-3000-checkins] r56418 ...

skip at pobox.com skip at pobox.com
Thu Jul 26 17:19:05 CEST 2007


    >> Run 2to3 over the Demo/ directory to shut up parse errors from 2to3
    >> about lingering print statements.

    Skip> Shouldn't the list(dictionary.keys()) construct only be applied
    Skip> where it's needed?

    Guido> Yeah, but the tool doesn't know when it is or isn't needed. You'd
    Guido> think that "for x in d.keys(): ..." would be a context where it's
    Guido> certainly not needed, but that's (alas) not true -- if the loop
    Guido> body modifies d, the list() call is needed. See various other
    Guido> recent checkins.

I wasn't complaining about the tool.  I fully expect it to wrap d.keys()
calls in list().  I thought the list() call should have been removed before
checking in the file though.

Skip


More information about the Python-3000-checkins mailing list