Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'hettinger': 0.07; 'alternatives': 0.09; 'rejected': 0.09; 'wrote': 0.14; 'container,': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'recipe': 0.16; 'specifying': 0.16; 'tjg': 0.16; 'try?': 0.16; 'wrote:': 0.18; 'properly': 0.19; 'code,': 0.22; 'header :User-Agent:1': 0.23; 'url:dev': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'points': 0.29; 'raymond': 0.30; 'subject:size': 0.31; 'url:python': 0.33; 'problem.': 0.35; 'limitations': 0.36; 'url:org': 0.36; 'list': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'dave': 0.60; 'complete': 0.62; "you've": 0.63; 'more': 0.64; 'from:addr:mail': 0.83; 'angel': 0.91 Date: Tue, 04 Feb 2014 19:28:41 +0000 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Finding size of Variable References: <8e4c1ab1-e65d-483f-ad9d-6933ae2052c3@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391542093 news.xs4all.nl 2830 [2001:888:2000:d::a6]:38851 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65446 On 04/02/2014 19:21, Dave Angel wrote: > Ayushi Dalmia Wrote in message: > >> >> Where am I going wrong? What are the alternatives I can try? > > You've rejected all the alternatives so far without showing your > code, or even properly specifying your problem. > > To get the "total" size of a list of strings, try (untested): > > a = sys.getsizeof (mylist ) > for item in mylist: > a += sys.getsizeof (item) The documentation for sys.getsizeof: http://docs.python.org/dev/library/sys#sys.getsizeof warns about the limitations of this function when applied to a container, and even points to a recipe by Raymond Hettinger which attempts to do a more complete job. TJG