iterating initalizations

D'Arcy J.M. Cain darcy at druid.net
Tue Dec 23 09:25:04 EST 2008


On Mon, 22 Dec 2008 22:32:17 -0500
Aaron Stepp <stepp.aaron at gmail.com> wrote:
> Instead of writing a long list of initializations like so:
> 
> A = [ ]
> B = [ ]
> ...
> Y = [ ]
> Z = [ ]
> 
> I'd like to save space by more elegantly turning this into a loop.  If  

Well, if all you want is a loop:

    for v in vars:
        locals()[v] = []

It's hard to tell if that's what you actually need though without
deeper analysis of your requirements.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list