Variable definition

Dave Angel davea at ieee.org
Fri Feb 26 23:56:20 EST 2010



Steven D'Aprano wrote:
> <snip>
>
> for key, value in varDic.iteritems():
>     varDic['myPrefix_' + key] = value
>     del varDic[key]
>
> <snip>
Watch out if any of the existing values already startswith 'myPrefix'  
You can end up with trouble just as confusing as if 'myPrefix' is an 
empty string

DaveA



More information about the Python-list mailing list