Parsing & question about usages off classes!

Dennis Lee Bieber wlfraed at ix.netcom.com
Sun Nov 3 16:43:48 EST 2002


Frans fed this fish to the penguins on Sunday 03 November 2002 11:58 am:
> 
> Ok. I am trying a different approach. But I am still having problems.
> 
> I want to create several new list. The name off the new lists will
> come from another list. That way I can create several lists, depending
> on the data received from logfiles. Is that possible ?
> 
> Or isnt that a good idea either ? :)
>
        You seem to be stuck on the idea of creating dynamic variable 
/names/... Though how do you intend to refer to those names later?
 
> So basicly:
> my_list['some','data']
> variable = my_list[0]
> variable = list
> 
> Now this doesnt work, but the result I want is a new list with the
> name 'some'.
> 
Python 2.2 (#1, Feb 24 2002, 16:21:58)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> dictoflists = {}
>>> alist = ['log1', 'log3', 'log2']
>>> for l in alist:
...     dictoflists[l] = []
...
>>> dictoflists
{'log2': [], 'log3': [], 'log1': []}
>>> dictoflists['log1'] = dictoflists['log1'] + ['data1']
>>> dictoflists['log1'] = dictoflists['log1'] + ['data3']
>>> dictoflists['log1']
['data1', 'data3']
>>>
>>> dictoflists['log1'].append('datan')
>>> dictoflists['log1']
['data1', 'data3', 'datan']
>>> dictoflists['log2'].append('datanew')
>>> dictoflists
{'log2': ['datanew'], 'log3': [], 'log1': ['data1', 'data3', 'datan']}

--  
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list