findall

Adding a parameter to a FindAll for a Generic List in C#

时间秒杀一切 提交于 2019-12-07 04:29:26
问题 I have a list of objects that I want to filter by an integer parameter List<testObject> objectList = new List<testObject>(); // populate objectList with testObjects objectList.FindAll(GroupLevel0); private static bool GroupLevel0(testObject item) { return item._groupLevel == 0; } private class testObject { public string _FieldSQL = null; public int _groupLevel; } What I'm looking to do is to make GroupLevel0 take in an integer as a parameter instead of hardcoding to 0. I'm working in .NET 2.0

Searching on class tags with multiple spaces and wildcards with BeautifulSoup

谁说我不能喝 提交于 2019-12-06 03:46:39
I am trying to use BeautifulSoup to find all div containers with the class attribute beginning by "foo bar". I had hoped the following would work: from bs4 import BeautifulSoup import re soup.findAll('div',class_=re.compile('^foo bar')) However, it seems that the class definition is separated into a list, like ['foo','bar'] , such that regular expressions are not able to accomplish my task. Is there a way I can accomplish this task? (I have reviewed a number of other posts, but have not found a working solution) You can use a syntax with a function that needs to return True or False , a lambda

Python - AttributeError: 'NoneType' object has no attribute 'findAll'

丶灬走出姿态 提交于 2019-12-05 21:20:19
I have written my first bit of python code to scrape a website. import csv import urllib2 from BeautifulSoup import BeautifulSoup c = csv.writer(open("data.csv", "wb")) soup = BeautifulSoup(urllib2.urlopen('http://www.kitco.com/kitco-gold-index.html').read()) table = soup.find('table', id="datatable_main") rows = table.findAll('tr')[1:] for tr in rows: cols = tr.findAll('td') text = [] for td in cols: text.append(td.find(text=True)) c.writerow(text) When I test it locally in my ide called pyCharm it works good but when I try it out on my server which runs CentOS, I get the following error:

Adding a parameter to a FindAll for a Generic List in C#

若如初见. 提交于 2019-12-05 08:27:06
I have a list of objects that I want to filter by an integer parameter List<testObject> objectList = new List<testObject>(); // populate objectList with testObjects objectList.FindAll(GroupLevel0); private static bool GroupLevel0(testObject item) { return item._groupLevel == 0; } private class testObject { public string _FieldSQL = null; public int _groupLevel; } What I'm looking to do is to make GroupLevel0 take in an integer as a parameter instead of hardcoding to 0. I'm working in .NET 2.0 so lambda expressions are a no-go. Is it even possible to pass a parameter into a predicate? Thank you

Why does re.findall return a list of tuples when my pattern only contains one group?

瘦欲@ 提交于 2019-12-05 06:46:32
Say I have a string s containing letters and two delimiters 1 and 2 . I want to split the string in the following way: if a substring t falls between 1 and 2 , return t otherwise, return each character So if s = 'ab1cd2efg1hij2k' , the expected output is ['a', 'b', 'cd', 'e', 'f', 'g', 'hij', 'k'] . I tried to use regular expressions: import re s = 'ab1cd2efg1hij2k' re.findall( r'(1([a-z]+)2|[a-z])', s ) [('a', ''), ('b', ''), ('1cd2', 'cd'), ('e', ''), ('f', ''), ('g', ''), ('1hij2', 'hij'), ('k', '')] From there i can do [ x[x[-1]!=''] for x in re.findall( r'(1([a-z]+)2|[a-z])', s ) ] to get

Grails: No signature of method findAll() is applicable for argument types: String, ArrayList

喜你入骨 提交于 2019-12-04 14:18:31
问题 I'm new to grails and receive the following error: No signature of method: Something.findAll() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [from Something AS s WHERE s.some_number LIKE ?, [%asdf%]]" The error occurs when I run test-app . It occurs in the following place: SomethingVO[] findBySomeNumber(String searchString) { searchString = "%"+searchString+"%" return Something.findAll("from Something AS s WHERE s.some_number LIKE ?",[searchString]).collect

beautifulsoup find_all bug?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 05:03:28
问题 Nowadays I am using beautiful soup to parse the html page. But sometimes the result I got by find_all is less than the number in pages. For example, this page http://www.totallyfreestuff.com/index.asp?m=0&sb=1&p=5 has 18 headline span. But when i use the following codes, it just got two! Can anybody tell me why. Thank you in advance! soup = BeautifulSoup(page, 'html.parser') hrefDivList = soup.find_all("span", class_ = "headline") #print hrefDivList print len(hrefDivList) 回答1: You can try

Groovy filter criteria on findAll on a list

谁都会走 提交于 2019-12-03 10:29:55
问题 I trying to build dynamic filters using findAll on a list. I have a variable that needs to be included in the filter only if not null. @Test void testSample(){ def list = [ new Employee(age:22, isManager:false), new Employee(age:23, isManager:true), new Employee(age:22, isManager:true) ] as Set def var = 22; String query1 = "it.age == var && it.isManager == true " String query2 = "it.isManager == true" println list println list.findAll { var ? query1 : query2 } // Should give 1 record age =

Grails: No signature of method findAll() is applicable for argument types: String, ArrayList

久未见 提交于 2019-12-03 08:59:36
I'm new to grails and receive the following error: No signature of method: Something.findAll() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [from Something AS s WHERE s.some_number LIKE ?, [%asdf%]]" The error occurs when I run test-app . It occurs in the following place: SomethingVO[] findBySomeNumber(String searchString) { searchString = "%"+searchString+"%" return Something.findAll("from Something AS s WHERE s.some_number LIKE ?",[searchString]).collect { new SomethingVO(it); } } The class Something is a domain object: package some.project.domain class

Groovy filter criteria on findAll on a list

…衆ロ難τιáo~ 提交于 2019-12-03 00:59:31
I trying to build dynamic filters using findAll on a list. I have a variable that needs to be included in the filter only if not null. @Test void testSample(){ def list = [ new Employee(age:22, isManager:false), new Employee(age:23, isManager:true), new Employee(age:22, isManager:true) ] as Set def var = 22; String query1 = "it.age == var && it.isManager == true " String query2 = "it.isManager == true" println list println list.findAll { var ? query1 : query2 } // Should give 1 record age = 22 and manager var = null; println list.findAll { var ? query1 : query2 } // should give 2 records-only