Re: undo a dictionary

2008-07-31 Thread mmm
Gabriel, I meant the latter, so this helps > Or, do you mean you already have those names and values, perhaps mixed   > with a lot more names, and want to extract only those starting with "x"   > and following with a number? > > result = {} > for name, value in vars(): # or locals().items(), or g

Re: undo a dictionary

2008-07-30 Thread castironpi
On Jul 30, 8:07 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 30 Jul 2008 16:14:31 -0300, mmm <[EMAIL PROTECTED]> escribi : > > > > >> > And for that matter a way to create a > >> > dictionary from a set of variables (local or global). > > >> You have to be more specific: there are {

Re: undo a dictionary

2008-07-30 Thread Gabriel Genellina
En Wed, 30 Jul 2008 16:14:31 -0300, mmm <[EMAIL PROTECTED]> escribi�: > And for that matter a way to create a > dictionary from a set of variables (local or global). You have to be more specific: there are {} displays and dict(args) call and other methods.  Read the manual. My desire is to ta

Re: undo a dictionary

2008-07-30 Thread Alan Franzoni
mmm was kind enough to say: > My desire is to take a set of data items in an alpha-numeric range and > oput them into a dictionary > > i.e., > x1=1 > x2=20 > x3=33 > > to yield the dictionary > > { 'x1':1, 'x2':20, 'x3':33 } > > without having to type in as above but instead invoke a function

Re: undo a dictionary

2008-07-30 Thread mmm
> > And for that matter a way to create a > > dictionary from a set of variables (local or global). > > You have to be more specific: there are {} displays and dict(args) call > and other methods.  Read the manual. My desire is to take a set of data items in an alpha-numeric range and oput them in

Re: undo a dictionary

2008-07-30 Thread Terry Reedy
mmm wrote: I found code to undo a dictionary association. def undict(dd, name_space=globals()): for key, value in dd.items(): exec "%s = %s" % (key, repr(value)) in name_space You are not undoing anything. You are updating globals() from another dict. But why

Re: undo a dictionary

2008-07-30 Thread bockman
On 30 Lug, 16:51, mmm <[EMAIL PROTECTED]> wrote: > I found code to undo a dictionary association. > > def undict(dd, name_space=globals()): >     for key, value in dd.items(): >         exec "%s = %s" % (key, repr(value)) in name_space > > So if i run > >

Re: undo a dictionary

2008-07-30 Thread Kay Schluehr
On 30 Jul., 16:51, mmm <[EMAIL PROTECTED]> wrote: > I found code to undo a dictionary association. > > def undict(dd, name_space=globals()): > for key, value in dd.items(): > exec "%s = %s" % (key, repr(value)) in name_space > > So if i run > &

undo a dictionary

2008-07-30 Thread mmm
I found code to undo a dictionary association. def undict(dd, name_space=globals()): for key, value in dd.items(): exec "%s = %s" % (key, repr(value)) in name_space So if i run >>> dx= { 'a':1, 'b': 'B'} >>> undict(dx) I get