Re: how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
Mark Lawrence於 2014年1月31日星期五UTC+8下午10時48分46秒寫道: > I'm pleased to see that you have answers. In return would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above, thanks. > My fellow Pythonistas, ask not what our lang

Re: how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
Skip Montanaro於 2014年1月31日星期五UTC+8下午6時29分27秒寫道: > Google for "python flatten list." > > > > This question comes up frequently, though I'm not sure if that's > > because it's a common homework problem or because people are unaware > > of the += operator (or extend method) for lists, and so buil

how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
a list like L = [[1, 2], [3, 4, 5], [6]], which has random numbers of list, which has random numbers. How do I get another list m = [1, 2, 3, 4, 5, 6] in a succinct way? ( or iterate them) I should provide my own solution, but I really can't come out with one. -- https://mail.python.org/mailman/

should I transfer 'iterators' between functions?

2014-01-24 Thread seaspeak
take the following as an example, which could work well. But my concern is, will list 'l' be deconstructed after function return? and then iterator point to nowhere? def test(): l = [1, 2, 3, 4, 5, 6, 7, 8] return iter(l) def main(): for i in test(): print(i) -- https://m

Re: Need Help with the BeautifulSoup problem, please

2013-12-16 Thread seaspeak
8 Dihedral於 2013年12月16日星期一UTC+8下午4時02分42秒寫道: > On Monday, December 16, 2013 2:41:08 PM UTC+8, seas...@gmail.com wrote: > > > I need to replace all tag with after ■. But the result from > > below is '■ D / ' > > > > > > Can you explain what I did wrong, please. > > > > > > > > > >

Re: Need Help with the BeautifulSoup problem, please

2013-12-16 Thread seaspeak
seas...@gmail.com於 2013年12月16日星期一UTC+8下午2時41分08秒寫道: > I need to replace all tag with after ■. But the result from below > is '■ D / ' > > Can you explain what I did wrong, please. > > > > s = '■A B C D / ' > > soup = BeautifulSoup(s) > > for i in soup.find_all(text='■'): > >

Need Help with the BeautifulSoup problem, please

2013-12-15 Thread seaspeak
I need to replace all tag with after ■. But the result from below is '■ D / ' Can you explain what I did wrong, please. s = '■A B C D / ' soup = BeautifulSoup(s) for i in soup.find_all(text='■'): tag = soup.new_tag('span') tag['style'] = 'REPLACE' for i