Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-25 Thread Yawar Amin
Hi Steven, On Saturday, January 24, 2015 at 11:27:33 PM UTC-5, Steven D'Aprano wrote: [...] Doesn't the traceback tell us exactly where the lambda was called from? Yes (assuming the source code is available, which it may not be), but If the source code is not available, then you're

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Yawar Amin
Hi, On Saturday, January 24, 2015 at 3:36:04 PM UTC-5, Devin Jeanpierre wrote: [...] Obviously, nobody will be happy until you can do: def call(*a, **kw): return lambda f: f(*a, **kw) @call() def x, y (): yield 1 yield 2 Actually, maybe not even then. You're probably right,

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Yawar Amin
Hi Ethan, On Saturday, January 24, 2015 at 9:00:12 PM UTC-5, Ethan Furman wrote: [...] __name__ being one of them. One of the reasons lambda is not encouraged is because its name is always 'lambda', which just ain't helpful when the smelly becomes air borne! ;) Doesn't the traceback tell

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Yawar Amin
On Friday, January 16, 2015 at 1:34:51 PM UTC-5, Peter Otten wrote: [...] I recommend that you use a generator: def walk(obj): ... if not hasattr(obj, keys): ... return ... if things in obj: ... yield obj[things] ... for v in obj.values(): ... yield

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Yawar Amin
On Friday, January 16, 2015 at 9:24:15 PM UTC-5, Yawar Amin wrote: [...] vals.extend(curr_obj.values()) Ah, I should mention that the above will do a breadth-first search. If we want to do a depth-first search we simply replace the above line with: vals.extendleft(curr_obj.values

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
On Thursday, January 15, 2015 at 1:40:09 AM UTC-5, Ian wrote: On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano steve@... wrote: [...] def func(a, b=None): global spam import math spam = [a, b]*3 print spam del spam value = [1, hello, int, func] del func

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
Hi, On Thursday, January 15, 2015 at 12:19:31 PM UTC-5, Rustom Mody wrote: [...] Looked at your suggestions... And then got distracted by your other project https://github.com/yawaramin/vim-cute-python Reminded me of what I had written some months ago along similar lines

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
On Thursday, January 15, 2015 at 10:06:34 PM UTC-5, Rick Johnson wrote: [...] Well i'm not religious in that way, but i can tell you that you'd be hard pressed to find a subject that did *NOT* annoy someone in this group. Heck, it might even be something like finding a holy grail if we all

lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread yawar . amin
Hi all, First off, to each reader--if you believe that 'multi-line' lambdas are no good and we can just use functions, decorators, c. to accomplish everything in Python, advance warning: this post will annoy you. Now, the crux of my message. I have implemented what I believe is a fairly robust,