gevent + urllib2 blocking

2013-02-22 Thread
Hi, One problem, thanks for help. import gevent.monkey gevent.monkey.match_all() from lxml import etree # I using xpath parse the html def _get(p): url = BUILD_URL(p) html = urllib2.urlopen(url) # RUN AT HERE AND BLOCKING # ver1 tree = etree.parse(html, parse) # ver

confused in decorate and closure

2012-09-12 Thread
HI, I have some test code: def num(num): def deco(func): def wrap(*args, **kwargs): inputed_num = num return func(*args, **kwargs) return wrap return deco @num(5) def test(a): return a + inputed_num print test(1) when run this code, I got

Re: Probability Algorithm

2012-08-25 Thread
On 08/25/2012 12:03 PM, 月忧茗 wrote: > > > In the FinalList, > > probability of ALIST's item appeared is 43% probability of BLIST's > > item appeared is 37% probability of CLIST's item appeared is 19% > > probability of DLIST's item appeared is

Re: Probability Algorithm

2012-08-25 Thread
Sorry, missing some conditions *already_picked_list* is get from db. > Why keep a counter? Rather than an iterated loop so , if use a iterated loop: for i in range(43): item = choice( ALIST ) ALIST.remove( item ) if item in already_picked_list: continue slot.appe

Probability Algorithm

2012-08-25 Thread
Hi, All, I have a problem of probability algorithm The goal is obtain a list which contains three items. as the *FinalList* There has Four source lists. * ALIST, BLIST, CLIST, DLIST There are all Unknown length. They contains unique elements* ( In fact, there are all empty at the program