removing items from a dictionary ?

Stef Mientki S.Mientki-nospam at mailbox.kun.nl
Thu Jul 26 16:58:15 EDT 2007


> 
> Since it isn't practical to iterate over Eagle_Power_Nets and test for 
> presence in your Nets dict, you have to iterate over at least the keys 
> of Nets. You could just iterate over the keys rather than the whole 
> table, though:
> 
>     for net in Nets.keys():
>     # Nets.iterkeys() would avoid building the list
>     # but that runs the same risks as your original
>         if net.upper() in  in Eagle_Power_Nets :
>             del Nets[net]
> 
thanks Steve,
that does the job.

> Watch that spacing, by the way: Python is easy to keep readable if you 
> follow the style guidelines of PEP 8.
Yeah, that's my great sin,
in all languages I always 2 spaces,
so that's the "best readable"  for me.
I still must write a beautifier,
that doubles spaces when a Python file leaves my computer ;-)

cheers,
Stef Mientki



More information about the Python-list mailing list