generating unique variable name via loops
mfthguven at gmail.com
Tue Nov 4 14:53:04 CET 2014
4 Kasım 2014 Salı 15:37:59 UTC+2 tarihinde Peter Otten yazdı:
> Veek M wrote:
> > Fatih Güven wrote:
> >> 4 Kas?m 2014 Sal? 13:29:34 UTC+2 tarihinde Fatih Güven yazd?:
> >>> I want to generate a unique variable name for list using python.
> >>> list1=...
> >>> list2=...
> > for x in range(1,10):
> > exec("list%d = " % x)
> Why would you do this?
I have a structured and repetitive data. I want to read a .txt file line by line and classified it to call easily. For example employee1 has a name, a salary, shift, age etc. and employee2 and other 101 employee have all of it.
Call employee1.name or employee2.salary and assign it to a new variable, something etc.
More information about the Python-list