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
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 {
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
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
> > 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
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 repr(value)? Wit
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
>
> >>> dx= { 'a':1, 'b': 'B'}
> >>> undict(dx)
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
>
> >>> dx= { 'a':1, 'b': 'B'}
> >>> undict(dx