Hi folks,
As promised, here's a follow-up to the withdrawn PEP 531 that focuses
on coming up with a common protocol driven solution to conditional
evaluation of subexpressions that also addresses the element-wise
comparison chaining problem that Guido noted when rejecting PEP 335.
I quite like ho
Thanks, Nick. This PEP is far easier to read than the previous one.
On 05.11.2016 10:50, Nick Coghlan wrote:
This PEP has been designed specifically to address the risks and concerns
raised when discussing PEPs 335, 505 and 531.
* it defines a new operator and adjusts the definition of chained
On 3 November 2016 at 23:06, Steven D'Aprano wrote:
> On Thu, Nov 03, 2016 at 12:35:07PM -0700, Chris Barker wrote:
> > On Thu, Nov 3, 2016 at 12:00 PM, MRAB
> wrote:
> >
> > > self.an_arg = the_default if an_arg is None else an_arg
> >
> > > No, ?? is a bit like 'or', except that only None is f
Long ago I posted a patch for this (decorator + context manager) but I
bumped into a weird error I wasn't able to fix (see last comment):
http://bugs.python.org/issue9285
On Wed, Nov 2, 2016 at 10:45 PM, Tim Mitchell
wrote:
> Hi Ben,
>
> Mostly I just print to stdout, I imagine more flexibility
Hi everyone,
Here is a simplification of a problem that's been happening in my code:
import contextlib
@contextlib.contextmanager
def f():
print('1')
try:
yield
finally:
print('2')
g = f()
g.__enter__()
This code prints 1 and then 2, not just 1 like you might expe
On 6 November 2016 at 14:46, Ram Rachum wrote:
> I worked around this problem by adding `except GeneratorExit: raise` in my
> context manager, but that's an ugly solution.
Adding `except GeneratorExit: raise` to a try statement with a finally
clause won't prevent the finally clause from executing
Sorry, I was wrong at quoting the workaround I do, it's actually this:
try:
yield
except GeneratorExit:
raise
except:
cleanup()
raise
else:
cleanup()
This works, but it'
Heh, I just played with this, and found a workaround. If I do something
like this after creating the generator:
sys.g = g
Then it wouldn't get closed when Python finishes, and the cleanup won't
happen, which is what I want. This is still a bit ugly but now it's
something I can do automatically fo
Python has very intuitive and clear syntax, except when it comes to method
definitions, particularly dunder methods.
class Vec(object):
def __init__(self, x, y):
self.x, self.y = x, y
def __add__(self, other):
return Vec(self.x + other.x, self.y + other.y)
def __getitem__
On 6 November 2016 at 16:07, Ram Rachum wrote:
> Heh, I just played with this, and found a workaround. If I do something like
> this after creating the generator:
>
> sys.g = g
>
> Then it wouldn't get closed when Python finishes, and the cleanup won't
> happen, which is what I want.
The interpre
10 matches
Mail list logo