On Thu, Mar 24, 2011 at 5:34 PM, Jins Thomas wrote:
> My problem was to find the occurance of each word in a file
>
> f = open('hello.txt', 'r')
> count = {}
> for line in f:
> words = line.split()
> for i in words :
> if i in count:
> count[i] += 1
> else:
>
Vishal wrote:
> size of the actual data. You should use something like this:
> http://code.activestate.com/recipes/546530/ . I saved this recipe by the
> name of PyObjSize which I have used below.
>
> >>> import PyObjSize
> >>> PyObjSize.asizeof(l)
> 3145848
> >>> l[0] = None
> >>> PyObjSize.asize
On Thu, Mar 24, 2011 at 05:34:58PM +0530, Jins Thomas wrote:
>
> I was just comparing hash in Perl. In Perl 'if i in count: else:' statement
> is not required i could simply uses count{i} +=1 even if it exists or not
> exists. I was thinking why Python has put this restriction. Or is it
> somethi
Hi all,
This is a very basic doubt. I was experimenting concept of dictionary in
python3
My problem was to find the occurance of each word in a file
f = open('hello.txt', 'r')
count = {}
for line in f:
words = line.split()
for i in words :
if i in count:
count[i] += 1
On Thu, Mar 24, 2011 at 12:07 PM, Senthil Kumaran wrote:
> On Thu, Mar 24, 2011 at 11:06:14AM +0530, Vishal wrote:
> > setting l[0] to None, un-references the earlier string data associated
> with
> > that name, which is then (force) collected by the collect() call.
>
> Can you please elaborate th