Re: reading dictionary's (key,value) from file

2008-04-07 Thread ankitks . mital
On Apr 7, 11:55 am, Robert Bossy <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Folks, > > Is it possible to read hash values from txt file. > > I have script which sets options. Hash table has key set to option, > > and values are option values. > > > Way we have it, we set options in a

reading dictionary's (key,value) from file

2008-04-07 Thread ankitks . mital
Folks, Is it possible to read hash values from txt file. I have script which sets options. Hash table has key set to option, and values are option values. Way we have it, we set options in a different file (*.txt), and we read from that file. Is there easy way for just reading file and setting opt

Re: python bisect questions

2008-04-04 Thread ankitks . mital
> > b) Define a function to extract a "key" from your items such that items   > compare the same as their keys. For example, key(x) -> x.lower() may be   > used to compare text case-insensitively. > Then, use a tuple (key, value) instead of the bare value. When extracting   > items from the queue,

having list attribute to track max size

2008-04-04 Thread ankitks . mital
Lets say I have a dynamic list class (may be extended from list), where I add and remove items during program. a = [] a.append(1) I am trying to find is there easy way keep track of 'maximum size of list reached" so for example len(a) goes from 0->3->4->3 If I call a.max_size_ever(), I will g

Re: python bisect questions

2008-04-03 Thread ankitks . mital
Thanks Gabriel -- http://mail.python.org/mailman/listinfo/python-list

Re: regarding memoize function

2008-04-03 Thread ankitks . mital
On Apr 3, 8:04 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop <[EMAIL PROTECTED]>   > escribió: > > > > > > > On Apr 3, 6:33 pm, [EMAIL PROTECTED] wrote: > >> I saw example of memoize function...here is snippet > > >> def memoize(fn, slot): > >>

regarding memoize function

2008-04-03 Thread ankitks . mital
I saw example of memoize function...here is snippet def memoize(fn, slot): def memoized_fn(obj, *args): if hasattr(obj, slot): return getattr(obj, slot) else: val = fn(obj, *args) setattr(obj, slot, val)

Re: python bisect questions

2008-04-03 Thread ankitks . mital
On Apr 3, 5:43 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Apr 4, 9:21 am, [EMAIL PROTECTED] wrote: > > > > > > > On Apr 3, 4:24 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > > > <[EMAIL PROTECTED]> wrote in message > > > >news:[EMAIL PROTECTED] > > > |I am week on functional programming, an

Re: python bisect questions

2008-04-03 Thread ankitks . mital
On Apr 3, 4:24 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > |I am week on functional programming, and having hard time > | understanding this: > | > | class myPriorityQueue: > |      def __init__(self, f=lamda x:x): > |            

python bisect questions

2008-04-03 Thread ankitks . mital
I am week on functional programming, and having hard time understanding this: class myPriorityQueue: def __init__(self, f=lamda x:x): self.A = [] self.f = f def append(self, item) bisect.insort(self.A, (self.f(item), item)) n

problem with sorting

2008-03-27 Thread ankitks . mital
>>> dict = {'M':3, 'R':0, 'S':2} >>> print dict {'S': 2, 'R': 0, 'M': 3} now if I wanted sorted values in list, i am not able to do this >>> print dict.values().sort() None it returns None instead of [0, 2, 3] -- http://mail.python.org/mailman/listinfo/python-list