Re: Naming dictionaries recursively

2007-08-18 Thread Paddy
On Aug 18, 11:44 am, TYR <[EMAIL PROTECTED]> wrote: > That sounds like a solution. I think the core of the question is as > follows; if I was to call the dict() function for each line, thus > creating a dictionary, and then rename it to dict['name'], will there > be a namespace collision on the nex

Re: Naming dictionaries recursively

2007-08-18 Thread TYR
That sounds like a solution. I think the core of the question is as follows; if I was to call the dict() function for each line, thus creating a dictionary, and then rename it to dict['name'], will there be a namespace collision on the next loop when dict() is called again? Obviously the first dict

Re: Naming dictionaries recursively

2007-08-17 Thread Paddy
On Aug 17, 3:43 pm, TYR <[EMAIL PROTECTED]> wrote: > > So the tougher problem seems to be parsing those lines. That is not a > > valid Python dictionary unless the names `Bob`, `Humboldt`, `red`, and > > `predatory` are not already defined. So you can't just ``eval`` it. > > In what way? {'key':

Re: Naming dictionaries recursively

2007-08-17 Thread Paul McGuire
On Aug 17, 7:38 am, TYR <[EMAIL PROTECTED]> wrote: > I'd like to do something like this; iterate through a file which > consists of data stored in dictionary format, one dict on each line, > and read each line into a new dict using one of the values in the dict > as its name... > > for example: > >

Re: Naming dictionaries recursively

2007-08-17 Thread TYR
> So the tougher problem seems to be parsing those lines. That is not a > valid Python dictionary unless the names `Bob`, `Humboldt`, `red`, and > `predatory` are not already defined. So you can't just ``eval`` it. In what way? {'key': val}, right? Anyway, I can always change the format they g

Re: Naming dictionaries recursively

2007-08-17 Thread Marc 'BlackJack' Rintsch
On Fri, 17 Aug 2007 12:38:16 +, TYR wrote: > I'd like to do something like this; iterate through a file which > consists of data stored in dictionary format, one dict on each line, > and read each line into a new dict using one of the values in the dict > as its name... Store the dictionaries

Re: Naming dictionaries recursively

2007-08-17 Thread [EMAIL PROTECTED]
On Aug 17, 7:38 am, TYR <[EMAIL PROTECTED]> wrote: > I'd like to do something like this; iterate through a file which > consists of data stored in dictionary format, one dict on each line, > and read each line into a new dict using one of the values in the dict > as its name... > > for example: > >

Naming dictionaries recursively

2007-08-17 Thread TYR
I'd like to do something like this; iterate through a file which consists of data stored in dictionary format, one dict on each line, and read each line into a new dict using one of the values in the dict as its name... for example: stuff = open('data.txt') for eachLine in stuff: name{} nam