Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-07 Thread Guido van Rossum
S3. Comprehensions and generator expressions should be interchangeable. They just look too similar to have different semantics (and the possibly delayed execution of generator expressions is not an issue -- it's rare, and closure semantics make it work just fine). -- --Guido van Rossu

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Guido van Rossum
s off he doesn't want to incur the overhead of evaluating the check. The assert statement has the latter property, but you have to use -O to turn it off. He basically wants a macro so that runtime_assert() expands to if and (): raise AssertionError In Lisp this would be easy

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Guido van Rossum
On Tue, May 8, 2018 at 12:29 AM, Eloi Gaudry wrote: > On Mon, 2018-05-07 at 10:52 -0700, Guido van Rossum wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > > wrote: > > > I just don't understand why you need a new keyword for writing > > > run

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-08 Thread Guido van Rossum
eating a second p in the containing scope -- either way it's probably a typo anyway. := outside a comprehension/genexpr is treated just like any other assignment (other than in-place assignment), i.e. it creates a local unless a nonlocal or global declaration exists. -- --Guido van

[Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
ver having to deal with ambiguities like `a, a+1 for a in range(10)` or `a for a in x, y`.) Another alternative would be to always require parentheses around `:=`, so that we would have to write `f((a := 1), 1)`. That's unambiguous, but otherwise just gets on the nerves. -- --Guido van Rossum

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
On Wed, May 9, 2018 at 8:42 PM, Chris Angelico wrote: > On Thu, May 10, 2018 at 1:33 PM, Guido van Rossum > wrote: > > (I vaguely recall this has been brought up before, but I'm too lazy to > find > > the subtread. So it goes.) > > > > PEP 572 curren

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-10 Thread Guido van Rossum
On Thu, May 10, 2018 at 5:17 AM, Nick Coghlan wrote: > On 9 May 2018 at 03:06, Guido van Rossum wrote: > >> So the way I envision it is that *in the absence of a nonlocal or global >> declaration in the containing scope*, := inside a comprehension or genexpr >> causes t

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-10 Thread Guido van Rossum
an attempting to restrict the construct purely to > if/elif/while. > > Even as a generally available postfix keyword, "given" should still be > amenable to the treatment where it could be allowed as a variable name in a > non-operator contex

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Guido van Rossum
On Thu, May 10, 2018 at 3:32 AM, Terry Reedy wrote: > On 5/9/2018 11:33 PM, Guido van Rossum wrote: > > I now think that the best way out is to rule `:=` in the top level >> expression of an expression statement completely >> > > I would like to be able to interactive

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Guido van Rossum
end I think they should be called "assignment expressions" just like in C. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-10 Thread Guido van Rossum
repeated many > times in the various email chains. (I preferred it as "as", but that's been > struck down already) (and if it's between ":=" and not having them at all, > I would rather just not have them) > > -- --Guido van Rossum (python.org/~guido)

Re: [Python-ideas] High Precision datetime

2018-05-10 Thread Guido van Rossum
I have to agree with David that this seems too specialized to make room for in the stdlib. On Thu, May 10, 2018, 15:16 David Mertz wrote: > This feels specialized enough to belong in a third party library. If that > library can behave as transparently as possible interacting with Python > dateti

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-10 Thread Guido van Rossum
Yes. On Thu, May 10, 2018, 13:18 Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > On Thu, May 10, 2018 at 9:44 AM, Guido van Rossum > wrote: > > I'm sorry, but unless there's a sudden landslide of support for 'given' > in > > fav

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-11 Thread Guido van Rossum
TE6 >> 18 POP_BLOCK >> 20 LOAD_CONST 0 (None) 22 RETURN_VALUE But for a generator: g = (x for x in C()) 1 0 LOAD_FAST0 (.0) >>2 FOR_ITER10 (to 14) 4

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-11 Thread Guido van Rossum
Maybe you could propose some kind of syntax using "whereas"? (It can be used as a preamble.) On Fri, May 11, 2018 at 3:05 AM, Greg Ewing wrote: > Guido van Rossum wrote: > >> I'd need well-reasoned explanations >> > > My reasoning is essentially the same a

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-11 Thread Guido van Rossum
uage designers could talk about such topic with as much confidence as they talk about the efficiency of hash tables. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/

[Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Guido van Rossum
to diagnose. I should also mention that this was inspired from some messages where Tim Peters berated the fashion of using "reserved words", waxing nostalgically about the old days of Fortran (sorry, FORTRAN), which doesn't (didn't?) have reserved words at all (nor signifi

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Guido van Rossum
I hereby withdraw the idea. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Guido van Rossum
x27;w'): > of.write(\if.read()) > > maybe even nicer than if_. > > Some examples: > > result = \except + 1 > > result = something.\except > > result = \except.\finally > > > -- > Steve > ___ > Py

Re: [Python-ideas] Modern language design survey for "assign and compare" statements

2018-05-19 Thread Guido van Rossum
nds. Maybe Python can set a new trend. It's happened before. :-) -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Modern language design survey for "assign and compare" statements

2018-05-21 Thread Guido van Rossum
dable based on hard facts alone, and hard but incredibly subtle facts related to the rest of the language's design and implementation (including the state of tooling and the structure of the compiler used as a reference implementation). So let's just end

Re: [Python-ideas] Meta-PEP about built-in functions

2018-05-22 Thread Guido van Rossum
This sounds fine to me. For type hint s we did a similar thing with PEPs 482, 483 and 484. You probably want to make everyone involved a co-author. On Tue, May 22, 2018, 14:29 Jeroen Demeyer wrote: > Hello, > > Both PEP 573 and PEP 575 deal with built-in functions. Additionally, > some people (S

Re: [Python-ideas] Was `os.errno` undocumented?

2018-05-29 Thread Guido van Rossum
Yes. What Steve says at the end. Let's be kind and mention this one on the release notes. But not all the others. On Tue, May 29, 2018, 07:57 Steven D'Aprano wrote: > On Tue, May 29, 2018 at 05:37:06PM +0300, Serhiy Storchaka wrote: > > > We have removed over 100 module attributes in 3.6 [2] and

Re: [Python-ideas] Add shutil.chown(..., recursive=False)

2018-05-29 Thread Guido van Rossum
rtunately provides some good precedent there, but it does > mean this feature would need to be implemented as its own API, rather than > as an option on shutil.chown. > > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > > _____

Re: [Python-ideas] Was `os.errno` undocumented?

2018-05-29 Thread Guido van Rossum
gt; On 5/29/2018 12:09 PM, Guido van Rossum wrote: > >> Yes. What Steve says at the end. Let's be kind and mention this one on >> the release notes. But not all the others. >> > > How about adding a general reminder. In Porting to 3.7: > > "Imports into

Re: [Python-ideas] Was `os.errno` undocumented?

2018-05-30 Thread Guido van Rossum
then that would wrongly > be detected as a non-public import. > > But most problematic, it does nothing about this case: > > import os > os.errno > > I think this is best left for linters. > > > -- > Steve > ______

Re: [Python-ideas] exception instantiation philosophy and practice [was: Let try-except check the exception instance]

2018-05-31 Thread Guido van Rossum
o create the instance >> before we can decide whether or not the raised >> exception matches the given exception handler criteria. >> > > Why is this? Doesn't the exception have to be instantiated at some point, > even if just to print to stderr? > Not if it gets

Re: [Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Guido van Rossum
gt; <https://pypi.org/project/generator_tools/> that purports to do this. I > haven't tried it yet to see if it still works in 2.x and it appears beyond > my skill level to port to 3.x. > > PyPy & Stackless Python apparently support this within certain limits? > > > Thoughts? > > &

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-20 Thread Guido van Rossum
> >> >> -- >> Steve >> ___ >> Python-ideas mailing list >> Python-ideas@python.org >> https://mail.python.org/mailman/listinfo/python-ideas >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
function. And similar for classmethod. > > (Of course calling classmethod instances directly won't work unless you > provide the class argument. But that's just a simple matter of bound > versus unbound methods.) > > > -- > Steve > ___ > Python-ideas ma

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
On Wed, Jun 20, 2018 at 9:31 AM Serhiy Storchaka wrote: > 20.06.18 19:20, Guido van Rossum пише: > > +1 -- when we introduced these we didn't see the use case so clearly, > > but it definitely exists. > > How would you call a classmethod descriptor in this case? >

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
On Wed, Jun 20, 2018 at 10:03 AM Serhiy Storchaka wrote: > 20.06.18 19:37, Guido van Rossum пише: > > On Wed, Jun 20, 2018 at 9:31 AM Serhiy Storchaka > > > <mailto:storch...@gmail.com>> wrote: > > > > 20.06.18 19:20, Guido van Rossum пише: >

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
eas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] POPT (Python Ob ject Provider Threads)

2018-06-20 Thread Guido van Rossum
; And yes I'm a little bit disappointed because it reduces the benefit of > my idea a lot. > Why would you be disappointed? Aren't you happy that you get much of the benefit without having to do any work? -- --Guido van Rossum (python.org/~guido) __

Re: [Python-ideas] Secure string disposal (maybe other inmutable seq types too?)

2018-06-22 Thread Guido van Rossum
tically flagged to be wiped). Downside: > You can't say "I'm done with this string, destroy it immediately". > > ChrisA > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mai

Re: [Python-ideas] Secure string disposal (maybe other inmutable seq types too?)

2018-06-22 Thread Guido van Rossum
eedn't either. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Allow mutable builtin types (optionally)

2018-06-26 Thread Guido van Rossum
t; neither implicitly nor explicitly ? > > I mean, our types are built-in and should be considered as immutable > across interpreters. And we (as most users I guess) are only running > one interpreter. > > In case several intepreters are used, it would make sense to have a > non

Re: [Python-ideas] Correct way for writing Python code without causing interpreter crashes due to parser stack overflow

2018-06-27 Thread Guido van Rossum
p://python-security.readthedocs.io/security.html#security-model > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Allow mutable builtin types (optionally)

2018-06-27 Thread Guido van Rossum
> Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

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

2018-06-27 Thread Guido van Rossum
gt; should be enum members, and cases where nested classes should not be > members. > > Thanks! > > -- > ~Ethan~ > ___________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] Add a __cite__ method for scientific packages

2018-06-27 Thread Guido van Rossum
r* > * Lab*Johns Hopkins University, Baltimore, USA. > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > --

Re: [Python-ideas] Add a __cite__ method for scientific packages

2018-06-28 Thread Guido van Rossum
for more information. >>> It makes total sense to add citations/references to this list (and those should probably print a reference for Python followed by instructions on how to get references for other packages and how to properly add a referenc

Re: [Python-ideas] grouping / dict of lists

2018-06-29 Thread Guido van Rossum
ent) >>> >> >> Thank you for bringing this up. I've been drafting a proposal for a >> better grouping / group-by operation for a little while. I'm not quite >> ready to share it, as I'm still researching use cases. >> >> I'm +1 that t

Re: [Python-ideas] grouping / dict of lists

2018-06-29 Thread Guido van Rossum
On Fri, Jun 29, 2018 at 3:23 PM Michael Selik wrote: > On Fri, Jun 29, 2018 at 2:43 PM Guido van Rossum wrote: > >> On a quick skim I see nothing particularly objectionable or controversial >> in your PEP, except I'm unclear why it needs to be a class method on

Re: [Python-ideas] grouping / dict of lists

2018-07-02 Thread Guido van Rossum
t; try to persuade you that `grouping` belongs in the built-ins. I revised my > draft to streamline the examples and make a clearer comparison with > existing tools. > Sorry, I'm not biting. This will not be a builtin nor a method on a builtin. I'm going to mute this thread be

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Guido van Rossum
ou everybody for you valuable feedback! I really appreciate your > time helping me thinking this through :) > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] anyone need a frozenset or bytearray literal?

2018-07-11 Thread Guido van Rossum
cannot >> c = [6, 7, 8] # cannot >> >> Disassemble this or look at f.__code__.co_consts and you'll see (1, 2, >> 3) as a single constant; but the others have to be built. >> >> +1 on set.freeze(); +0 on bytes.to_bytearray().

Re: [Python-ideas] slice[] to get more complex slices

2018-07-23 Thread Guido van Rossum
7;t need a metaclass -- it can be implemented as __class_getitem__. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-08-28 Thread Guido van Rossum
__iadd__ pairwise. But I am not so keen, because the ambiguity of `a, b, c += x`. Perhaps someone can do some research and unearth real code that contains series of += assignments that would become more readable by collapsing them into a single line using the proposed construct. -- --Guido van

Re: [Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?

2018-08-30 Thread Guido van Rossum
llow top-level function calls to be written without parentheses, but it was too hard to make it unambiguous (e.g. would "foo +1" mean "foo(+1)" or "foo + 1"?) -- --Guido van Rossum (python.org/~guido) ___ Python-idea

Re: [Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?

2018-08-30 Thread Guido van Rossum
On Fri, Aug 31, 2018 at 4:04 AM, David Mertz wrote: > On Thu, Aug 30, 2018 at 9:41 PM Guido van Rossum wrote: > >> On Fri, Aug 31, 2018 at 3:19 AM, Michael Selik wrote: >> >>> On Thu, Aug 30, 2018 at 5:31 PM James Lu wrote: >>> >>>> It would

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-13 Thread Guido van Rossum
nadian actress named Samantha Quan. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEPs: Theory of operation [was: Moving to another forum system ...]

2018-09-22 Thread Guido van Rossum
elp prospective authors based on the text they show us. I have to admit that I've not followed the full context, but I recommend that you try to see that other posters in this thread are trying to help with kindness, not judging you or your skills

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Guido van Rossum
Gah! You are overthinking it. This idea is only worth it if it's dead simple, and the version that Eric posted to start this thread, where !d uses the repr() of the expression, is the only one simple enough to bother implementing. -- --Guido van Rossum (python.org/~

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Guido van Rossum
to > the empty coffee pot. > > -- > Jonathan > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) _

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Guido van Rossum
k > with YAML or perhaps something even simpler than either one. > I feel the same way. (Somebody was requesting extensive TOML support for mypy and was also waving those PEPs in front of us.) -- --Guido van Rossum (python.org/~guido) __

Re: [Python-ideas] Introduce typing.SupportsFsPath

2018-10-08 Thread Guido van Rossum
lement new objects (without > dependency to "Path") > that are implementing the __fspath__ protocol. > > robert > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/pytho

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-21 Thread Guido van Rossum
dlock. Nathaniel, would you be able to elaborate more on the issue of backpressure? I think a lot of people here are not really familiar with the concepts and its importance, and it changes how you have to think about queues and the like. -- --Guido van Rossum (python.org/~

Re: [Python-ideas] Return for assignment blocks

2018-10-24 Thread Guido van Rossum
ause because there's no trouble with switching between expression-mode and statement-mode. Also note that syntactically it is clearly a special form of `def` statement -- it can even be decorated! So let's review the proposal as a shorthand for defining a function and immediate

Re: [Python-ideas] Return for assignment blocks

2018-10-25 Thread Guido van Rossum
e") the use case is just much narrower. So unless we find more use cases, or until we can convince ourselves that we can use `def (args): block` in all expression contexts, I guess it'll have to remain an idea. Thank you though! It was a fascinating one. -- --Guido van Rossum (python.org/~guido

Re: [Python-ideas] name2type mapping

2018-10-25 Thread Guido van Rossum
ed with static type checking (PEPs 484, 526, 544, 561) it may be PEP-worthy. As a compromise, perhaps some discussion can take place in the issue tracker of the repo (https://github.com/guettli/python-name2type-mapping) Thomas created? If someone with PEP experience is interested they can guide T

Re: [Python-ideas] Decide if `type.__subclasses__` is part of future Python or not

2018-10-29 Thread Guido van Rossum
ns "__subclasses__() -> list of > immediate subclasses" > > To fully figure out what it did, I had to read the source code to Python > -- which really is not the best way to figure out what a function does; > hence the request to document it (and indicate it's fut

Re: [Python-ideas] Allow Context Managers to Support Suspended Execution

2018-11-01 Thread Guido van Rossum
ed > with as. > > Thanks, > > David > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] dict.setdefault_call(), or API variations thereupon

2018-11-01 Thread Guido van Rossum
The two are less connected than you seem to think. On Thu, Nov 1, 2018 at 7:08 PM Alex Shafer wrote: > I had actually managed to miss collections.defaultdict! > > I'd like to instead propose that a reference to that be added to the > dict.setdefault docs. I can't imagine I'm the only one that ha

Re: [Python-ideas] dict.setdefault_call(), or API variations thereupon

2018-11-01 Thread Guido van Rossum
instance is created, while setdefault() is used when inserting a value. A major issue IMO with defaultdict is that if you try to *read* a non-existing key it will be inserted. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Pyt

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Guido van Rossum
them, I think other stdlib libraries are not beholden to that behavior.) -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Dict joining using + and +=

2019-02-27 Thread Guido van Rossum
dea. After all, we have `list.extend(x)` ~~ `list += x`. The key conundrum that needs to be solved is what to do for `d1 + d2` when there are overlapping keys. I propose to make d2 win in this case, which is what happens in `d1.update(d2)` anyways. If you want it the oth

Re: [Python-ideas] Dict joining using + and +=

2019-02-27 Thread Guido van Rossum
x27; + 'a'. For non-numbers we only require + to be associative, i.e. a + b + c == (a + b) + c == a + (b + c). That is satisfied for this proposal. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.

Re: [Python-ideas] Dict joining using + and +=

2019-02-27 Thread Guido van Rossum
x27;b': 3}) > > At first I worried that changing base dict would cause confusion for the > subclass, but Counter seems to share the idea that update and + are > synonyms. > Great, this sounds like a good argument for + over |. The other argument is that | for sets

Re: [Python-ideas] Dict joining using + and +=

2019-02-27 Thread Guido van Rossum
erested in sponsoring the PEP. And I'm not it. Is there a core dev who is interested in sponsoring or co-authoring this PEP? -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman

Re: [Python-ideas] Dict joining using + and +=

2019-02-27 Thread Guido van Rossum
x27;t in d2. > > > > -- > Steven > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (p

Re: [Python-ideas] Dict joining using + and +=

2019-02-28 Thread Guido van Rossum
On Wed, Feb 27, 2019 at 11:18 PM Serhiy Storchaka wrote: > 27.02.19 20:48, Guido van Rossum пише: > > > > On Wed, Feb 27, 2019 at 10:42 AM Michael Selik > > > <mailto:m...@selik.org>> wrote > The dict subclass > collections.Counter overrides the

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-01 Thread Guido van Rossum
e of Conduct: http://python.org/psf/codeofconduct/ > > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread Guido van Rossum
is highly non-obvious except if you've already encountered that pattern before, while d1+d2 is what anybody familiar with other Python collection types would guess or propose. And the default semantics for subclasses of dict that don't override these are

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread Guido van Rossum
d list + list, so this seems an unwarranted worry to me. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread Guido van Rossum
On Mon, Mar 4, 2019 at 12:12 PM Neil Girdhar wrote: > On Mon, Mar 4, 2019 at 2:26 PM Guido van Rossum wrote: > > > > * Dicts are not like sets because the ordering operators (<, <=, >, >=) > are not defined on dicts, but they implement subset comparisons for s

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread Guido van Rossum
Honestly I would rather withdraw the subtraction operators than reopen the discussion about making dict more like set. On Mon, Mar 4, 2019 at 12:33 PM Neil Girdhar wrote: > On Mon, Mar 4, 2019 at 3:22 PM Guido van Rossum wrote: > > > > On Mon, Mar 4, 2019 at 12:12 PM Neil G

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-04 Thread Guido van Rossum
g naming conventions or type annotations. > Those two points make me uncomfortable with "+=" strictly behaving > like ".update()". > And yet that's how it works for lists. (Note that dict.update() still has capabilities beyond +=, since you can also invoke it with keyword args.) -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Suggestions: dict.flow_update and dict.__add__

2019-03-05 Thread Guido van Rossum
gs): > self.update(*argv, **kwargs) > return self > > def copy(self): > return self.__class__(self) > > A DIRTY HACK > Not tested, using an assignment expression. >dict_arg = (tmp := defaults.copy(), tmp.update(optio

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-05 Thread Guido van Rossum
nted without hashing, e.g. using a balanced tree, so that it could support unhashable keys). If there's doubt about this anywhere, we could add an example to the docs and to the PEP. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-05 Thread Guido van Rossum
t as long as they are *strings* such keys should be allowed. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-05 Thread Guido van Rossum
rst, none of the other situations I listed above raises for conflicts. Second, there's the experience of str+unicode in Python 2, which raises if the str argument contains any non-ASCII bytes. In fact, we disliked it so much that we changed the language incompatibly to deal with it. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Dict joining using + and +=

2019-03-05 Thread Guido van Rossum
y > > other obvious meaning that + and * could have for sets. > > The language SETL (the language of sets) also uses + and * for set > operations.¹ > So the secret is out: Python inherits a lot from SETL, through ABC -- ABC was heavily influenced by SETL. > ¹ https://www.li

[Python-ideas] OT: about hasty posts from phones

2019-03-06 Thread Guido van Rossum
e better. NOTE: I'm not picking on you specifically Chris! I see this a lot, and I do it myself too (and regularly regret it). -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/m

Re: [Python-ideas] dict literal allows duplicate keys

2019-03-06 Thread Guido van Rossum
recall, in SGML the first value "original" is the one that is > in effect. This is what happens with the LaTeX command > \providecommand. > > FURTHER LINKS > [6] > https://docs.python.org/3/reference/expressions.html#dictionary-displays > [7] https://cwe.mitre.org/data/definitions/561.html # CWE-561: Dead Code > &

Re: [Python-ideas] unittest: 0 tests pass means failure of the testsuite

2019-03-06 Thread Guido van Rossum
ibed) > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-08 Thread Guido van Rossum
> In the spirit of full disclosure: > Of these, 2 is already implemented and widely used, so we don't need > to use dict.__add__ for that. I've never seen 4 in the mathematical > literature (union of relations is not the same thing). 3, however, is > very common both for mappings with small domain and sparse > representation of mappings with a default value (possibly computed > then cached), and "|" is not suitable for expressing that sort of > addition (I'm willing to say it's "wrong" :-). > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-08 Thread Guido van Rossum
On Fri, Mar 8, 2019 at 3:33 PM Greg Ewing wrote: > Guido van Rossum wrote: > > I guess this explains the behavior of removing results <= 0; it makes > > sense as multiset subtraction, since in a multiset a negative count > > makes little sense. (Though the name Counter c

[Python-ideas] Why operators are useful

2019-03-15 Thread Guido van Rossum
r me this is the default assumption (even at Dropbox -- our most performance critical code has already been rewritten in ugly Python or in Go). For the few cases where performance concerns are paramount, it's easy to transform the operator version to something else -- *once you've confirmed i

Re: [Python-ideas] Why operators are useful

2019-03-15 Thread Guido van Rossum
On Fri, Mar 15, 2019 at 9:19 PM Inada Naoki wrote: > On Sat, Mar 16, 2019 at 2:51 AM Guido van Rossum wrote: > > > > But I think that the folks who point out "there is already a way to do > this" are missing the point that it really is easier to grasp the meaning &

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-21 Thread Guido van Rossum
elling, then I think > this proposal is the best: explicit, unambiguous, immediately > understandable and easy to remember. > I don't find it easy to understand or remember that d1.update(d2) modifies d1 in place, while d1.merge(d2) first copies d1. Maybe the name can

Re: [Python-ideas] Enabling / disabling optional type hinting

2019-03-23 Thread Guido van Rossum
not much of a reason to try and introduce a mechanism to disable type hints. Sorry. PS. This particular syntax was introduced by PEP 526, and introduced in Python 3.6. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas

Re: [Python-ideas] META: Is a PEP a good place to record Python's core design decisions and coding principles?

2019-03-24 Thread Guido van Rossum
nd > many more bugs. > > SUMMARY > > I have argued that Python's core design decisions and coding principles > can, at least in part, be reduced to a system of AXIOMS that can be useful > applied. I have argued mainly based on analogy with the Hindu-Arabic > numeral system, and the life and work of Gauss. > > > > > > > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] New explicit methods to trim strings

2019-03-25 Thread Guido van Rossum
ategory error. > I assume the whole proposal was a pastiche of the proposal to add a + operator for dictionaries. Jonathan needs to come clean before more people waste their time discussing this. -- --Guido van Rossum (python.org/~guido) ___ Pyt

Re: [Python-ideas] Built-in parsing library

2019-03-31 Thread Guido van Rossum
sing as the main candidate that fits this bill. >>>> >>>> What do you say? >>>> >>>> Thanks! >>>> Nam >>>> ___ >>>> Python-ideas mailing list >>>> Python-ideas@py

Re: [Python-ideas] Add output() helper function to subprocess module

2019-04-04 Thread Guido van Rossum
Let’s please leave this alone. As Serhiy says run() covers everything. On Thu, Apr 4, 2019 at 3:03 AM Oleg Broytman wrote: > On Thu, Apr 04, 2019 at 07:44:29PM +1100, Chris Angelico > wrote: > > On Thu, Apr 4, 2019 at 7:12 PM Nathaniel Smith wrote: > > > > > > On Thu, Apr 4, 2019 at 12:48 AM G

Re: [Python-ideas] What are the strong use cases for str.rindex()?

2019-04-23 Thread Guido van Rossum
a list of comma-separated items for the last comma, a fully-qualified module name for the last period, and some ad-hoc parsing of other things. The "last separator" use cases are the most common and here rindex() sounds very useful. -

Re: [Python-ideas] CPython Bytecode Assembler

2019-04-24 Thread Guido van Rossum
lman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him/his **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> ___

Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-24 Thread Guido van Rossum
irst time posting an idea to python-ideas. So apologies if i > am not following some conventions that i might not be aware of. > Vaibhav Karve > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinf

Re: [Python-ideas] Users of statistics software, what quantile functionality would be useful for you?

2019-04-28 Thread Guido van Rossum
re = data[max(0, index - 1)] after = data[min(len(data) - 1, index)] return (before + after) / 2.0 where `data` is a sorted array. Essentially we use the average of the two values nearest the cutoff point, except for edge cases. (I think we could do better, but this is the code I found in our

<    1   2   3   4   5   6   7   8   9   10   >