Re: [BangPypers] Return values

2014-10-03 Thread Noufal Ibrahim KV
On Thu, Sep 25 2014, Saager Mhatre wrote: [...] > Alternatively, would it be possible to model Stats/StatsList as a composite > hierarchy (potentially with Courtesy Implementations > )? [...] I didn't know about Courtesy implementation

Re: [BangPypers] Return values

2014-10-03 Thread Noufal Ibrahim KV
On Thu, Sep 25 2014, Saager Mhatre wrote: [...] > Alternatively, would it be possible to model Stats/StatsList as a composite > hierarchy (potentially with Courtesy Implementations > )? [...] I didn't know about Courtesy implementation

Re: [BangPypers] Python List Comprehension Question

2014-10-03 Thread Bhargav Kowshik
We could use what Anand talked about at Pycon India about handling the headers in first row of a CSV.In this scenario, instead of default for result being None and checking if None everytime, we could have the default value an empty list. def flat_it(values, result=list()):     for v in values:

Re: [BangPypers] Python List Comprehension Question

2014-10-03 Thread Anand Chitipothu
On Fri, Oct 3, 2014 at 8:26 PM, Bhargav Kowshik < bhargav.kows...@yahoo.com.dmarc.invalid> wrote: > We could use what Anand talked about at Pycon India about handling the > headers in first row of a CSV.In this scenario, instead of default for > result being None and checking if None everytime, we

Re: [BangPypers] Python List Comprehension Question

2014-10-03 Thread Bhargav Kowshik
Nice! Thank you very much Anand.But, I still don't know what is happening.Please point me to a resource to understand what is happening. ** Program ** def flat_it(values, result=list()):     for v in values:     if isinstance(v, list):     flat_it(v, result)     else:    

Re: [BangPypers] Python List Comprehension Question

2014-10-03 Thread kracekumar ramaraju
On Fri, Oct 3, 2014 at 9:04 PM, Bhargav Kowshik < bhargav.kows...@yahoo.com.dmarc.invalid> wrote: > Nice! Thank you very much Anand.But, I still don't know what is > happening.Please point me to a resource to understand what is happening. > > A common beginner mistake. More of such gotcha can be f

Re: [BangPypers] Python List Comprehension Question

2014-10-03 Thread Bhargav Kowshik
Thank you Kracekumar. http://docs.python-guide.org/en/latest/writing/gotchas/#what-you-wrote"Python’s default arguments are evaluated once when the function is defined,not each time the function is called." Thank you, Bhargav. On Friday, October 3, 2014 9:18 PM, kracekumar ramaraju wro