thanks for the reply. i should have been more specific in my question ;)
the order in which 'other' is listed is not always the last item of
the list as it is dependent on where in the CSV file it is included.
what i was trying to do is to take create the list of dictionary items
and then find
thanks for the reply, i think i have it now, perhaps it could be done better
http://pastie.org/1186545
On Tue, Sep 28, 2010 at 2:56 PM, Emile van Sebille em...@fenx.com wrote:
Hi Norman,
Read my reply again -- that's the second question I answered.
Emile
On 9/28/2010 12:56 AM Norman
Norman Khine wrote:
thanks for the reply, i think i have it now, perhaps it could be done
better
topics.sort(key=itemgetter('name'))
for i, t in enumerate(topics):
... for (k, v) in t.iteritems():
... if v == 'other':
... topics.append(topics.pop(i))
On 9/28/2010 7:12 AM Norman Khine said...
thanks for the reply, i think i have it now, perhaps it could be done better
I think I'd use a helper function to sort:
def sortOtherToEnd(val):
if val['name'] == 'other:
return ''
return val['name']
#then sort it
thank you, here is the updated version:
http://pastie.org/1186860
On Tue, Sep 28, 2010 at 5:50 PM, Emile van Sebille em...@fenx.com wrote:
On 9/28/2010 7:12 AM Norman Khine said...
thanks for the reply, i think i have it now, perhaps it could be done
better
I think I'd use a helper
On 9/28/2010 9:37 AM Norman Khine said...
thank you, here is the updated version:
http://pastie.org/1186860
The only obvious redundancy is the duplicated sort of options just
before the return. You only need the newer sort_key based one.
Emile
ok, great.
one thing i wanted to ask is how could i extend the class so that i
can just change the name of the csv file?
On Tue, Sep 28, 2010 at 6:53 PM, Emile van Sebille em...@fenx.com wrote:
On 9/28/2010 9:37 AM Norman Khine said...
thank you, here is the updated version:
On 9/27/2010 1:22 PM Norman Khine said...
what is the correct way to ensure that {'industry': 'travel', 'name':
'other','value': MSG(uOther)} is always added to the end of this
list after all the items have been sorted?
here is the code which returns this list: