On Wednesday, February 5, 2014 7:13:34 PM UTC+5:30, Dave Angel wrote: > Ayushi Dalmia <ayushidalmia2...@gmail.com> Wrote in message: > > > On Wednesday, February 5, 2014 12:59:46 AM UTC+5:30, Tim Chase wrote: > > >> On 2014-02-04 14:21, Dave Angel wrote: > > >> > > >> > To get the "total" size of a list of strings, try (untested): > > >> > > >> > > > >> > > >> > a = sys.getsizeof (mylist ) > > >> > > >> > for item in mylist: > > >> > > >> > a += sys.getsizeof (item) > > >> > > >> > > >> > > >> I always find this sort of accumulation weird (well, at least in > > >> > > >> Python; it's the *only* way in many other languages) and would write > > >> > > >> it as > > >> > > >> > > >> > > >> a = getsizeof(mylist) + sum(getsizeof(item) for item in mylist) > > >> > > >> > > >> > > >> -tkc > > > > > > This also doesn't gives the true size. I did the following: > > > > > > import sys > > > data=[] > > > f=open('stopWords.txt','r') > > > > > > for line in f: > > > line=line.split() > > > data.extend(line) > > > > > > print sys.getsizeof(data) > > > > > > > Did you actually READ either of my posts or Tim's? For a > > container, you can't just use getsizeof on the container. > > > > > > a = sys.getsizeof (data) > > for item in mylist: > > a += sys.getsizeof (data) > > print a > > > > -- > > DaveA
Yes, I did. I now understand how to find the size. -- https://mail.python.org/mailman/listinfo/python-list