Posts

Sort Object in List

บันทึกการ sort object ที่สร้างจาก class ที่ต้องการใน list class chromosome: def __init__(self,err): self.err = some error value ........ class content ....... suppose c1,c2,c3,c4 create from class chromosome and hav attr err every instance >>mlist = [c1,c2,c3,c4] if we want sort by attr err .... :) we need import operator and do mlist.sort(key=operator.attrgetter('err')) haha i think i got what i want!!!!

yoh, Sort dict

have a problem with sorting dict by value!!! found something interesting on http://code.activestate.com/recipes/304440/ by Nick Coghlan let's see >>d = {'a':0,'b':1,'c':2} >>d #will get {'a':0,'c':2,'b':1} some solution from Nick >>from operator import itemgetter >>print sorted(d.items(),key=itemgetter(1)) #we get [('a':0),('b':1),('c':2)] # >>>>> a list of tuples it might be useful in the future!!!:) thank nick and activestate

Using Pydev and Eclipse for Prototyping

Image
I'm doing a proof of concept model by using Viterbi Algorithm (cause confusing of matlabs' view and hungry to use python), By Eclipse IDE and PyDev ... Things will be like this below!!!!! *ps capture image from gimp Hope this work will be done ,soon!!!! :> and detail will come out later---:

Hello World

Hello My New Blog, We'll hav fun together :o