Re: [BangPypers] parsing xml

2011-08-01 Thread Kenneth Gonsalves
On Sun, 2011-07-31 at 19:57 +0530, Anand Balachandran Pillai wrote: xml parsing in the case when all that you need from the string is a simple numeric value(not a string), then good luck; unlike esr i will not use adjectives; but i would not use your code either. To be fair here, I

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Balachandran Pillai
On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar asif.jama...@rezayat.netwrote: What if I have two lists for both minimum and maximum values Minimum Maximum 0 10 11 20 21 30 31 40 Now how should I check if actual result is not laying

Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 12:43 AM, Noufal Ibrahim nou...@gmail.com wrote: Dhananjay Nene dhananjay.n...@gmail.com writes: [...] re.search(distance\s*(\d+)\s*/distance,data).group(1) would appear to be the most succinct and quite fast. Adjust for whitespace as and if necessary.

Re: [BangPypers] parsing xml

2011-08-01 Thread Kiran Jonnalagadda
On 31-Jul-2011, at 11:33 PM, Venkatraman S wrote: A regex is the simplest IMHO, because you need not know the syntax of the minidom parser. But, again i have seen this quiet often that lack of knowledge of regexp has led people to other solutions (the grapes are sour!) In the eternal words

[BangPypers] #lazyweb - How would the wsgi lite proposal help in ..

2011-08-01 Thread Dhananjay Nene
After Armin Ronacher's post http://lucumr.pocoo.org/2011/7/27/the-pluggable-pipedream/ P. J. Eby responded with http://dirtsimple.org/2011/07/wsgi-is-dead-long-live-wsgi-lite.html with an implementation at https://bitbucket.org/pje/wsgi_lite/ While I could potentially read up the details and

Re: [BangPypers] parsing xml

2011-08-01 Thread Anand Balachandran Pillai
On Mon, Aug 1, 2011 at 1:25 PM, Kiran Jonnalagadda j...@pobox.com wrote: On 31-Jul-2011, at 11:33 PM, Venkatraman S wrote: A regex is the simplest IMHO, because you need not know the syntax of the minidom parser. But, again i have seen this quiet often that lack of knowledge of regexp

Re: [BangPypers] parsing xml

2011-08-01 Thread Smrutilekha Swain
by using lxml...for example-: from lxml import etree content = etree.iterparse( *name of the xml file*, events=('start', 'end')) for event, elem in content: if elem.tag == 'distance': print elem.text Hope it will work.. On Mon, Aug 1, 2011 at 1:43 PM,

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar asif.jama...@rezayat.net wrote: What if I have two lists for both minimum and maximum values Minimum  Maximum 0               10 11              20 21              30 31              40 Now how should I check if actual result is not laying

Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 12:46 AM, Noufal Ibrahim nou...@gmail.com wrote: Venkatraman S venka...@gmail.com writes: Hang around in #django or #python. The most elegant code that you *should* write would invariably be pretty fast (am not ref to asm). I agree with you here. Pythonicity is best

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Chitipothu
2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar asif.jama...@rezayat.net wrote: What if I have two lists for both minimum and maximum values Minimum  Maximum 0               10 11              20 21              30 31              40 Now

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar asif.jama...@rezayat.net wrote: What if I have two lists for both minimum and maximum values Minimum  Maximum 0      

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Baishampayan Ghose
On Mon, Aug 1, 2011 at 4:38 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: I also find map much more atomic and portable construct to think in - after all every list comprehension is syntactic sugar around map + filter, and map/reduce/filter are far more omnipresent than list

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Chitipothu
2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar asif.jama...@rezayat.net wrote: What if I have two lists for both

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Chitipothu
2011/8/1 Baishampayan Ghose b.gh...@gmail.com: On Mon, Aug 1, 2011 at 4:38 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: I also find map much more atomic and portable construct to think in - after all every list comprehension is syntactic sugar around map + filter, and map/reduce/filter

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Baishampayan Ghose
On Mon, Aug 1, 2011 at 5:09 PM, Anand Chitipothu anandol...@gmail.com wrote: I also find map much more atomic and portable construct to think in - after all every list comprehension is syntactic sugar around map + filter, and map/reduce/filter are far more omnipresent than list comprehensions.

Re: [BangPypers] #lazyweb - How would the wsgi lite proposal help in ..

2011-08-01 Thread Anand Chitipothu
2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: After Armin Ronacher's post http://lucumr.pocoo.org/2011/7/27/the-pluggable-pipedream/ P. J. Eby responded with http://dirtsimple.org/2011/07/wsgi-is-dead-long-live-wsgi-lite.html with an implementation at https://bitbucket.org/pje/wsgi_lite/

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:07 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Sat, Jul 30, 2011 at 2:15 PM, Asif

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 4:41 PM, Baishampayan Ghose b.gh...@gmail.com wrote: On Mon, Aug 1, 2011 at 4:38 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: I also find map much more atomic and portable construct to think in - after all every list comprehension is syntactic sugar around map +

Re: [BangPypers] #lazyweb - How would the wsgi lite proposal help in ..

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:41 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: [..] How could the above proposal (if it does) help in a) Creating simpler, lighter frameworks (eg. flask) b) Help support greater asynchronicity (a la tornado,

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Balachandran Pillai
On Mon, Aug 1, 2011 at 5:07 PM, Anand Chitipothu anandol...@gmail.comwrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Sat, Jul 30, 2011 at 2:15 PM,

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:44 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:07 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1 Dhananjay Nene dhananjay.n...@gmail.com: On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu anandol...@gmail.com wrote: 2011/8/1

Re: [BangPypers] parsing xml

2011-08-01 Thread Noufal Ibrahim
Anand Balachandran Pillai abpil...@gmail.com writes: On Mon, Aug 1, 2011 at 6:08 AM, Anand Chitipothu anandol...@gmail.comwrote: [...] It is more subtler than that. List comprehensions are faster than map functions when the latter needs to invoke a user-defined function call or a lambda.

[BangPypers] [Python Workshop] in Bangalore

2011-08-01 Thread director guruprevails
Dear Python Community, This is to inform you that GuRu Prevails is conducting a Python workshop starting 3rd August 2011. The timings are as follows 3rd August 2011 - 6 P.M. - 10 P.M 4th August 2011 - 6 P.M. - 10 P.M. 10th August 2011 - 4 P.M. - 10 P.M. 11th August 2011 - 5 P.M. - 10 P.M. The

Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 7:51 PM, Noufal Ibrahim nou...@gmail.com wrote: Anand Balachandran Pillai abpil...@gmail.com writes: On Mon, Aug 1, 2011 at 6:08 AM, Anand Chitipothu anandol...@gmail.comwrote: [...] It is more subtler than that. List comprehensions are faster than map functions

[BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Anand Chitipothu
I knew there was a way to better implement flatmap - its a combination of itertools.chain.from_iterable and map. Here's a much cleaner code from itertools import chain print filter(lambda (x,y,z) : x*x + y*y == z*z,    chain.from_iterable(map(        lambda x: chain.from_iterable(map(    

[BangPypers] Map vs List comprehensions (was Re: parsing xml)

2011-08-01 Thread Anand Balachandran Pillai
On Mon, Aug 1, 2011 at 7:51 PM, Noufal Ibrahim nou...@gmail.com wrote: Anand Balachandran Pillai abpil...@gmail.com writes: On Mon, Aug 1, 2011 at 6:08 AM, Anand Chitipothu anandol...@gmail.com wrote: [...] It is more subtler than that. List comprehensions are faster than map

Re: [BangPypers] Map vs List comprehensions

2011-08-01 Thread Noufal Ibrahim
Anand Balachandran Pillai abpil...@gmail.com writes: [...] Maybe I should have rephrased it like this. - If using anonymous functions, prefer list comps over map. - If using built-in functions (C functions), prefer map over list comps. - If using pythonic user functions, there is nothing

Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu anandol...@gmail.com wrote: I knew there was a way to better implement flatmap - its a combination of itertools.chain.from_iterable and map. Here's a much cleaner code from itertools import chain print filter(lambda (x,y,z) : x*x + y*y == z*z,

Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu anandol...@gmail.com wrote: I was trying to translate Python list-comprehensions into Javascript and here is what I've come up with. $pyjs.listcomp(    function(x, y, z) { return [x, y, z]},    [        range(1, 100),        function(x) {

Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Anand Balachandran Pillai
On Mon, Aug 1, 2011 at 7:51 PM, Dhananjay Nene dhananjay.n...@gmail.comwrote: On Mon, Aug 1, 2011 at 7:26 PM, Anand Balachandran Pillai abpil...@gmail.com wrote: IMHO, map/filter/reduce and the inevitable companion lambda were added on to Python when it was still trying to find its