newbie question about self and eval
Sami Hangaslammi
shang.remove_edu at st.jyu.fi.edu
Tue Jan 25 06:03:01 EST 2000
Prateep Siamwalla <teep at danaicorp.com> wrote in message
news:86jjkj$jmu$1 at news.inet.co.th...
--8<--
I don't know if this is the cleanest way to do it in Python, but I'd
use self.__dict__ which is a dictionary of the object's data (see
below).
> class myclass:
>
> def __init__(self,filename='c:\\test.txt'):
> self.fee = []
> self.fi = []
> self.fo = []
> self.fum = []
> f = open(filename,'r')
> rl = f.readlines()
> f.close()
> for lines in rl:
> token = string.split(lines,'\011')
self.__dict__[token[0]].append(token[1])
Note that the dictionary is (of course) case sensitive, so you might
want to use self.__dict__[string.lower(token[0])].
--
Sami Hangaslammi
shang (at) st (dot) jyu (dot) fi
Get paid to surf the Web!
http://www.alladvantage.com/home.asp?refid=BOT021
More information about the Python-list
mailing list