Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
> In the particular case I did it in, I needed the incremental results > passed to a function, not just the final result. I don't think this > made it into the final code, rather it was expanded to be more > readable. But the discovery made me feel a disturbance in the > Pythonic force of the uni

Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
> d = {} > for key, d[key] in (("this",18), ("that",17), ("other",38)): > print key > do_something(d) > Why not use a dict comprehension? d = {k:v for k,v in (("this",18), ("that",17), ("other",38))} I feel this is more straightforward and easier to read. the results are the same how

Re: help needed

2013-04-08 Thread Barrett Lewis
Do you happen to be on windows? Because if you are then you need to edit the registry. If you are on windows let me know and I will walk you through the fix, but if not then it would be a waste of time for me to explain it. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do a Lispy-esque read?

2013-04-08 Thread Barrett Lewis
> For example, if the input stream contained the text: > [1, # python should ignore this comment > 2] > > and I do a "read" on it, I should obtain the result > [1, 2] > -- > I don't know much about lisp but given that input and the desired output you can write functions like the following def str

Re: Formatting lost in hg-web (was Re: with ignored)

2013-04-08 Thread Barrett Lewis
I am viewing it on Chrome Version 26.0.1410.43 m for windows and it works perfectly for me. On Mon, Apr 8, 2013 at 12:32 AM, Chris Angelico wrote: > On Mon, Apr 8, 2013 at 4:38 PM, Barrett Lewis > wrote: > > I looked up the source to the decorator > > found here: >

Re: with ignored

2013-04-07 Thread Barrett Lewis
> > However, ignored() is actually implemented as a generator function > with the @contextmanager decorator shortcut. This decorator takes a > generator function and wraps it up as a class with the necessary > __enter__ and __exit__ methods. The __enter__ method in this case > calls the .next() m

with ignored

2013-04-07 Thread Barrett Lewis
I was recently watching that Raymond Hettinger video on creating Beautiful Python from this years PyCon. He mentioned pushing up the new idiom with ignored(): # do some work I tracked down his commit here http://hg.python.org/cpython/rev/406b47c64480 But am unsure how the yield works in the