[ANN]:JSONStream
I was trying to process a large file containing a number of distinct JSON object as a stream, but I couldn't find anything readily available to that. (maybe I didn't search hard enough) So I came up with this: https://github.com/qrtz/JSONStream I hope you find it useful too. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: [ANN]:JSONStream
I didn't look into using YAML processor. Also that would have required pre-processing the data to add the separators. With this method you don't need the separators. You can have 0 or more white space between objects: for obj in JSONStream(StringIO('''{one:1}{two:2}{three:3} 4 {five: 5}''')): print(obj) {one:1} {two:2} {three:3} 4 {five:5} It solved my problem, so I thought someone might find it useful. On Wed, Jul 17, 2013 at 11:51 AM, Clark C. Evans c...@clarkevans.com wrote: ** Looks interesting. In YAML we used three dashes as the stream separator. So already a YAML processor could handle a JSON stream ... for doc in yaml.load_all( ... --- {one: value} ... --- {two: another} ... --- ... {three: a third item in the stream, ... with: more data} ... ): ... print doc ... {'one': 'value'} {'two': 'another'} {'with': 'more data', 'three': 'a third item in the stream'} -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[ANN]:JSONStream
I was trying to process a large file containing a number of distinct JSON object as a stream, but I couldn't find anything readily available to that. (maybe I didn't search hard enough) So I came up with this: https://github.com/qrtz/JSONStream I hope you find it useful too. -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to decide between PHP and Python
There. Now that I've tossed some gasoline on the language wars fire, I'll duck and run in the other direction :-) May I suggest a better strategy? Run first, duck next :-). Or more precisely: ((run) duck) If you're going to mock another language, you might as well get it right :-) If that's Lisp code, it should be: (funcall (run) duck) Did you mean (progn #'run #'duck) -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
Most of the examples presented here can use the decorator pattern instead. Especially the window system On Mon, Nov 29, 2010 at 5:27 PM, Gregory Ewing greg.ew...@canterbury.ac.nzwrote: Paul Rubin wrote: The classic example though is a window system, where you have a window class, and a scroll bar class, and a drop-down menu class, etc. and if you want a window with a scroll bar and a drop-down menu, you inherit from all three of those classes. Not in any GUI library I've ever seen. Normally there would be three objects involved in such an arrangement, a Window, a ScrollBar and a DropDownMenu, connected to each other in some way. -- Greg -- http://mail.python.org/mailman/listinfo/python-list -- http://www.afroblend.com African news as it happens. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
Try this: '(?Psomething\S+)(,|$)' On Thu, Nov 25, 2010 at 9:40 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? JM -- http://mail.python.org/mailman/listinfo/python-list -- http://www.afroblend.com African news as it happens. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to improve this code?
def are_elements_present(sourceList, searchList):for e in searchList: if e not in sourceList: return False return True Using set: def are_elements_present(sourceList, searchList): return len(set(sourceList).intersection(set(searchList)) == len(searchList) On Tue, Sep 15, 2009 at 11:11 AM, Oltmans rolf.oltm...@gmail.com wrote: On Sep 15, 1:13 pm, Hendrik van Rooyen hend...@microcorp.co.za wrote: (i) a True if All the elements in match are in aList, else False? (ii) a True if any one or more of the members of match are in aList? (iii) Something else? That's a good question because I failed miserably in explaining my problem clearly. My original question isn't what I'm trying to solve. My apologies. I will try to explain here clearly. I'm using a 3rd- party library named Selenium (used for web-automation) and it has a method named is_element_present(ele) i.e. takes one element and return true if it finds this element in the page's HTML and returns false otherwise. Given this, I'm just trying to write a method are_elements_present(aList) whose job is to return True if and only if all elements in aList are present in page's HTML. So here is how are_elements_present() looks like def are_elements_present(eleLocators): elePresent=False if not eleLocators: return False for ele in eleLocators: if selenium.is_element_present(ele): elePresent=True else: elePresent=False print 'cannot find this element= '+str(ele) break return elePresent Now suppose page HTML contains with these IDs ( ID is an attribute like input id=inp1 /) = div1,div2,div3,div4,div5,inp1,inp2 and if I call the above method this way are_elements_present ([div1,div2,inp1,inp2]) then it should return True. If I call like are_elements_present([div1,div2,div10,inp1]) it should return False. So I hope I've explained myself. Now all I'm looking for is to write are_elements_presents() in a more Pythonic way. So please let me know if I can write are_elements_present() in more smart/shorter way. Thanks a lot for your help, in advance. Best regards, Oltmans -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list