Python allows for breaking out from a loop through 'break' and
'continue' keywords. It would be nice if it was possible to break many
loop levels using one command.
I propose two constructions for that:
break
break break
break break break
...
continue
break continue
break break continue
..
The concrete example I was working on when I started to miss double
break. This is an implementation of polynomial long division in Galois
field. Almost unmodified.
With outer break, I would't need to use the `running` variable. In fact,
for mathematical clarity, I would like to put a test
How about doing it pythonic way then, "everything is a hack on a symbol
table".
Let normal loops remain normal loops.
Let's introduce a special construction:
> for x in iterator as loop_control_object:
> loop_body(loop_control_object)
The iterator in the loop would be wrapped inside
Could we add __enter__ and __exit__ to the tuple type?
Look at the following code:
a = open('a.tmp', 'w')
b = open('b.tmp', 'w')
with (a, b) as (af, bf):
af.write("1")
bf.write("2")
Even better example:
with tuple(open(str(_n) + '.tmp', 'w') for _n in range(1000)) as f:
for
ns, invariants will be checked only in debug mode.
I am developing a library for formal proofs and such a feature would be
handy.
haael
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to python-ideas-le...@pyt
he assymetry: there is a nice way to hint
functions, but there is none to hint loops.
haael
I'd have to agree with Steven here, I'm -0 on the proposal since it's
not convincing (at least at the moment).
haael wrote:
> Python has more and more optional tools for formal c
.
To specify invariants on `while` loops we could do something like:
while loop_invariant(condition) and running:
loop_body
so no new syntax is needed.
With this syntax, annotatin loops with invariants would be possible
without changing indentation.
haael
Hello Everyone,
If
f the diff touches half of the lines of the code, it
will never be merged.
We can quickly annotate functions with decorators and type hints (both
are one-liners).
We can quickly specify assertions (one-liner).
Now give me one-liner for loop invariants.
On 11/04/20 10:20 am, haael wrote:
Forgive me if this has already been discussed.
Could we add the idea of "negative" sets to Python? That means sets that
contain EVERYTHING EXCEPT certain elements.
First, let's have a universal set that contains everything.
assert element in set.UNIVERSAL
The universal set is a super
Only objects of globally defined classes are picklable:
class Global:
pass
picklable = Global()
def f():
class Local:
pass
return Local
Local_here = f()
unpicklable = Local_here()
However, instances become picklable if we assign the l
know how to create the class...
>
> Apologies if I'm misunderstanding your point here, but it feels like
> what you're proposing would only work if you pickled and unpickled the
> data in the *same* running instance of the program.
>
> Paul
>
On Thu, 3 Sep 2020 at 1
NotImplemented
This would be somewhat analogous to `else if` blocks.
This pattern is very common in operator implementations. And this
proposal could simplify it a bit.
haael
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an
ddle of
code is silently ignored, but I don't think anybody seriously relies on
that behavior.
haael
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mai
Python has the "star" ("*") operator for multiplication. In the context of
collections it is supposed to mean element-wise multiplication. Its associated
operator is __mul__. It also has the double star ("**") operator for
exponentiation, which is repeated multiplication. Its associated operator
14 matches
Mail list logo