Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Elazar
other, related idea: instead of "??" use a double-token operator "! or": value = ham! or spam! or eggs optdict = dict(encoding=encoding! or sys.getdefaultencoding(), css=options.css) Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-07 Thread Elazar
inside a with block, therefore, > doesn't make sense and can only lead to obscure bugs. > Instead of disallowing code, this is a case for allowing with expressions: def read_multiple(*filenames): for filename in filenames: yield (f.read() with open(filename) as

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Elazar
h the addition of the returning that you have to track. Jumping to functions is procedural programming. There is no reasonfor it to be "considered harmful" any more than calling funcions; indeed even less so. Elazar On Wed, Aug 15, 2018, 17:42 Eric Fahlgren wrote: > How

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-16 Thread Elazar
You might also be interested in pep-563 <https://www.python.org/dev/peps/pep-0563/>. although it is not intended for design by contract, it can help (syntactically). Elazar On Wed, Aug 15, 2018 at 11:07 PM Marko Ristin-Kaufmann < [email protected]> wrote: > Hi, >

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Elazar
"=>" will make this possible: def x => x def x: int => x def x: int -> int => x It will also give one less meaning to the colon. Elazar On Tue, Aug 21, 2018 at 6:28 PM MRAB wrote: > On 2018-08-22 01:25, Jonathan Fine wrote: > > Hi Abe > > >

Re: [Python-ideas] CoC violation

2018-09-21 Thread Elazar
ramming languages (probably trolling, as several people before me have pointed out). Elazar > Rhodri James schrieb am Fr., 21. Sep. 2018 um > 15:46 Uhr: > >> On 20/09/18 19:56, Brett Cannon wrote: >> > Based on the WG's recommendation and after discussing it with

Re: [Python-ideas] Simplicity of C (was why is design-by-contracts not widely)

2018-09-30 Thread Elazar
ser code need pnly be aware of the specification, not the implementation. So method that _are_ overridden retain their contracts. This is precisely like with types, since types are contracts (and vice versa, in a way). Elazar ___ Python-ideas mailing lis

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-19 Thread Elazar
Related: https://github.com/python/mypy/issues/2103 - Elazar On Fri, Oct 19, 2018 at 2:15 PM Anders Hovmöller wrote: > > > > On 19 Oct 2018, at 12:15, Steven D'Aprano wrote: > > > > On Fri, Oct 19, 2018 at 09:18:02AM +0200, Thomas Güttler wrote: > > >

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-06 Thread Elazar
irection of avoiding exceptions altogether, not adding more intricate control flow directives. This proposal is basically about introducing goto to the language. Elazar בתאריך יום ב׳, 7 בינו׳ 2019, 5:07, מאת Richard Damon ‏< [email protected]>: > On 1/6/19 9:54 PM, simon.bordey

Re: [Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS

2019-01-29 Thread Elazar
de that does declare it, which can really help when reaaoning about the code, or debugging it, as it makes many potential sources of bugs less likely. Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/pytho

Re: [Python-ideas] Why operators are useful

2019-03-18 Thread Elazar
ntiable, and all of those > thing will be true for it. > > Mathematicians abstract things this way all the time. Groups, > fields, vector spaces, etc. are all very abstract concepts, > defined only as a set of objects having certain properties. > If that's not duck typing, I

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Elazar
You have AssertionError for that. Elazar בתאריך יום ה׳, 11 באפר׳ 2019, 1:10, מאת Stefano Borini ‏< [email protected]>: > I occasionally found situations where I want to raise an exception for > errors that can only arise because the developer made a mistake, for > ex

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2017-11-27 Thread Elazar
important - failure will be caught relatively soon. And I believe that the ability to remove the check at runtime is important, since isinstance calls have non-negligible impact on performance in mypy. (but other contributors here can correct me on this). Elazar בתאריך יום ג׳, 28 בנוב׳ 2017, 09:12

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2017-11-28 Thread Elazar
; > > - assert is a statement *solely* so that the compiler can optimise it > > out. If it's not optional, > >it doesn't need to be a statement any more > Another benefit of a statement vs function is only evaluating the > error-related arguments when there'

Re: [Python-ideas] [Python-Dev] What's the status of PEP 505: None-aware operators?

2017-11-29 Thread Elazar
condition ? first : second > > for the ternary if operator. > This suggests something like "ifNone" keyword : x = a ifNone b ifNone c Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] [Python-Dev] What's the status of PEP 505: None-aware operators?

2017-11-29 Thread Elazar
ing when used in a conditinal statement or a comprehension. x = a if x else y else b # wait. what? Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] [Python-Dev] What's the status of PEP 505: None-aware operators?

2017-11-29 Thread Elazar
nary operation? If any of these is allowed, it might confuse people. It also break the ability to extract subexpression to variables. (I kinda like this idea, but it doesn't look like a small, simple change to the language, whereas ?? does). Elazar ___

Re: [Python-ideas] Descouraging the implicit string concatenation

2018-03-14 Thread Elazar
+ "string that the compiler puts together") > > > Or allow unary plus: long_string = ( + "some part of the string " + "with more words, actually is the same " + "string that the compiler puts together" ) Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Fixing class scope brainstorm

2018-03-25 Thread Elazar
t classes to behave like comprehensions - i.e. code that is not delayed will see the class' scope as an enclosing scope (since it is not namespaced yet so there's no other way to refer to it) and delayed code (e.g. lambdas or defs) will not. Elazar __

Re: [Python-ideas] Rewriting file - pythonic way

2018-04-15 Thread Elazar
This pitfall sounds like a good reason to have such a function in the standard library. Elazar בתאריך יום א׳, 15 באפר׳ 2018, 13:13, מאת Serhiy Storchaka ‏< [email protected]>: > 15.04.18 12:49, Alexey Shrub пише: > > В Воскресенье, 15 апр. 2018 в 12:40 , Serhiy Storchaka > &

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-01 Thread Elazar
I think this method is easy to miss, since people look at the docs for bytes (e.g. using dir(bytes)). It might be worthwhile to either add a `bytes.to_int(...)` method (better, IMHO), or to point to int.from_bytes on the relevant part of the docs. Elazar On Tue, May 1, 2018 at 5:09 PM Ken Hilton

Re: [Python-ideas] ternary without else

2018-05-25 Thread Elazar
The title is misleading - this has nothing to do with the conditional operator, except small syntactic similarity. Elazar בתאריך יום ו׳, 25 במאי 2018, 05:40, מאת Jacco van Dorp ‏< [email protected]>: > 2018-05-25 14:26 GMT+02:00 Kirill Balunov : > > If it is an expressi

Re: [Python-ideas] Should nested classes in an Enum be Enum members?

2018-06-27 Thread Elazar
People working with sum types might expect the instances of the nested class to be instances of the enclosing class. So if the nested class is a namedtuple, you get a sum type. The only problem is that there's no way to express this subtype relationship in code. Elazar בתאריך יום ד׳, 27

Re: [Python-ideas] Should nested classes in an Enum be Enum members?

2018-06-27 Thread Elazar
ted) ideas here: https://github.com/python/mypy/issues/2464 Not the best link out there but it explains: https://antonioleiva.com/sealed-classes-kotlin/ Elazar On Wed, Jun 27, 2018 at 12:49 PM Ryan Gonzalez wrote: > I *think* he's referring to something like this: > > class A(

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Elazar
d similar doubts about adding > the matrix-multiplication operator @.) > It is just as specific as the `is` operator, and for the same reason. Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/pyt

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Elazar
I know it is not generally considered a bad addition in any of these languages, all of which put emphasis on readability. Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/