[Python-ideas] Re: 'Infinity' constant in Python

2020-09-05 Thread Guido van Rossum
onstant, and I don't like that option at all. I also don't think this is quite as big a deal as it seems to have become in your head. So please put it to rest. There are many other worthy causes. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <htt

[Python-ideas] Re: Proposed new syntax for subscripting (was PEP 472)

2020-09-02 Thread Guido van Rossum
an be done relatively cleanly with changes at both the bytecode level and the C API level. I'm not sure I like this better than the "pure `__getitem__/__setitem__` scheme, because the API duplication is troublesome, -- --Guido van Rossum (python.org/~gui

[Python-ideas] Re: Changing item dunder method signatures to utilize positional arguments (open thread)

2020-09-01 Thread Guido van Rossum
reaction will be > "Why the flipping heck not?" > > Which is why I was somewhat perplexed when it was suggested that we > should discount this use case purely because it wasn't cited in the > original proposal (which turned out to be wrong anyway). > I agree it's a fine use case. U

[Python-ideas] Re: PEP-0472 revisited - draft

2020-09-01 Thread Guido van Rossum
__`, that method is called. Extending this with keyword args is straightforward. Modifying the compiler to generate different bytecode for this case is essentially impossible. See https://github.com/python/cpython/blob/6844b56176c41f0a0e25fcd4fef5463bcdbc7d7c/Objects/abstract.c#L181-L198 for the c

[Python-ideas] Re: Proposed new syntax for subscripting (was PEP 472)

2020-09-01 Thread Guido van Rossum
you add some cases that show how `d[1]` differs from `d[1,]`? (And perhaps explain the reason why `d[1, k=2]` follows `d[1]` instead of `d[1,]`. I know the answer, but it's worth being clear about this particular edge case because it has tripped up various attempts.) -- --Guido van Rossum (pytho

[Python-ideas] Re: Proposed new syntax for subscripting (was PEP 472)

2020-09-01 Thread Guido van Rossum
and find a separate sponsor. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> ___ Python-ideas mailing list -- pytho

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-31 Thread Guido van Rossum
ray implementers they don't care *how* keywords work as long as their users can write a[1, 2, k=3]. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> ___

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-31 Thread Guido van Rossum
On Sun, Aug 30, 2020 at 11:56 PM Greg Ewing wrote: > On 31/08/20 4:11 pm, Guido van Rossum wrote: > > Okay, and if I write > > a.__getitem__((1, 3), k=2) will the function see the same thing? > > No, it will see (i, j, k) == (1, 3, 2). > That was a typo. I meant to ask w

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-31 Thread Guido van Rossum
gt; for users of such classes. > Which leads to what design choices? I think we need to watch out that we're not trying to make `a[1, 2, k=3]` look like a function call with funny brackets. It is a subscript operation with keyword parameters. But it is still first and foremost a subscript operation.

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
passed through all the C API layers until it reaches the tp slots. In particular it would uglify PyObject_[GS]etItemEx. -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le..

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
arently a handy (:-) feature to work around this. There's an attachment named "attachment.htm". If you click to download this and then open the downloaded file in the browser, it shows the original message in plaintext. Yeah, it's not ideal, but at least it proves that I did type what I meant. :-

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
simplest proposal possible -- keyword args get added to the end of `__getitem__` and `__setitem__`, ensuring that `d[1, k=3]` is like `d[1]` + keyword, not like `d[1,]` + keyword. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
You appear to be making a connection between star-args in a call and in a function definition. They are unrelated. The more I hear about this the more I favor not supporting it in the subscript syntax. On Sun, Aug 30, 2020 at 08:44 Joseph Martinot-Lagarde wrote: > Guido van Rossum wr

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
iling list -- python-ideas@python.org > > To unsubscribe send an email to python-ideas-le...@python.org > > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/LBK

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
IMPORTANT CORRECTION! I was too eager to get to bed and made a mistake in the summary for the d[1, a=3] cases. The key here should be '1', not '(1,)'. On Sun, Aug 30, 2020 at 12:45 AM Guido van Rossum wrote: > A quick summary of the proposal at the pure Python level: > > ``` &g

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-30 Thread Guido van Rossum
On Sat, Aug 29, 2020 at 10:29 PM Guido van Rossum wrote: > FYI, Jonathan's post (once I "got" it) led me to a new way of reasoning > about the various proposals (__keyfn__, __subscript__ and what I will keep > calling "Steven's proposal") based on what the compiler

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-29 Thread Guido van Rossum
ive conclusion is that Steven's proposal is superior. But I have been reviewing my reasoning and pseudo-code a few times and I'm still not happy with it, so posting it will have to wait. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-29 Thread Guido van Rossum
On Sat, Aug 29, 2020 at 4:08 PM Guido van Rossum wrote: > [...] > Finally, I am unsure how you would deal with the difference between d[1] > and d[1,], which must be preserved (for `__keyfn__ = True` or absent, for > backwards compatibility). The bytecode compiler cannot as

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-29 Thread Guido van Rossum
ever I see a __setitem__ function I must look everywhere else in the class (and in all its base classes) for a __keyfn__ before I can understand how the __setitem__ function's signature is mapped from the d[...] notation. Finally, I am unsure how you would deal with the difference between d[1] and d[

[Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access

2020-08-29 Thread Guido van Rossum
mail to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/R2ZLF7HF5WRHWHYB3J6UESUU24OHGXWL/ > Code of Conduct: http://python.org/psf/codeofcondu

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
assign an > ABC set (e.g. I get a warning with `foo(t= collections.abc.Set>)`. The problem then is that `collections.abc.Set[int]` > doesn't work, i.e. you need to use typing.Set if you want generics. > -- --Guido van Rossum (python.org/~guido

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
WTYFNTKW7PHONUCD3U2S3OO/ >> ). >> >> Anyway, thank you for this. I'm enjoying the discussion and I'm glad to >> hear actual reasons that can be argued about rather than the proposal just >> fizzling away. >> >> >> >> >>

[Python-ideas] Re: Type Implications in Python 4 (or 3.9)

2020-08-26 Thread Guido van Rossum
On Wed, Aug 26, 2020 at 11:20 AM Christopher Barker wrote: > > > On Wed, Aug 26, 2020 at 9:02 AM Guido van Rossum > >> Mypy includes an experimental compiler from typed Python to C that >> actually does what the OP is looking for. >> >> https://gith

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
On Wed, Aug 26, 2020 at 10:45 AM Alex Hall wrote: > On Wed, Aug 26, 2020 at 7:30 PM Guido van Rossum wrote: > >> But for your convenience you are proposing a problematic change (see >> posts by others). >> > > I think we've established it's problematic

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
But for your convenience you are proposing a problematic change (see posts by others). Maybe I meant overgeneralization instead. On Wed, Aug 26, 2020 at 10:20 AM Alex Hall wrote: > On Wed, Aug 26, 2020 at 4:32 PM Guido van Rossum wrote: > >> FWIW I don’t think we should add a .

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
Yes. That's what I meant by "the mixins are part of the contract", sorry. On Wed, Aug 26, 2020 at 8:45 AM Greg Ewing wrote: > On 27/08/20 2:32 am, Guido van Rossum wrote: > > The mixins are part of the contract. You are free to override them, > > their implementation

[Python-ideas] Re: Type Implications in Python 4 (or 3.9)

2020-08-26 Thread Guido van Rossum
n as type annotations, but those are primarily used for type checking > using tools such as mypy and are not used by the interpreter itself. > Mypy includes an experimental compiler from typed Python to C that actually does what the OP is looking for. https://github.com/python/mypy/tree/master/my

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-08-26 Thread Guido van Rossum
; > Python-ideas mailing list -- python-ideas@python.org > > To unsubscribe send an email to python-ideas-le...@python.org > > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > > Message archived at > https://mail.python.org/archives/list/python-ideas@python.or

[Python-ideas] Re: Adding additionnal common request handlers to http.server

2020-08-24 Thread Guido van Rossum
To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/DO457OZPWKJZHPYDY54C6TT5K5H44IT7/ > Code of Conduct: http://python.or

[Python-ideas] Re: FEATURE REQUEST: Make `logging` Module more Pythonic

2020-08-24 Thread Guido van Rossum
Well then you can keep wondering. On Mon, Aug 24, 2020 at 13:59 Stefano Borini wrote: > On Mon, 24 Aug 2020 at 21:54, Guido van Rossum wrote: > > > > > > Because all the git history would be lost, and lots of code would break. > > > > Well, names could have b

[Python-ideas] Re: FEATURE REQUEST: Make `logging` Module more Pythonic

2020-08-24 Thread Guido van Rossum
for the stdlib. > > > > > > IIUC, both the logging and unittest design were inspired (if not > directly ported) from Java. Which explains their out-of-place feeling > design. As the say, “Python is not Java” — so maybe Python should not log > and test like java? > > >

[Python-ideas] Re: FEATURE REQUEST: Make `logging` Module more Pythonic

2020-08-24 Thread Guido van Rossum
ilman3/lists/python-ideas.python.org/ > > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/BK6P32YAUZ2D763LJXKI6WNVUNHQIBKH/ > > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- --Guido (mobile) ___

[Python-ideas] Re: Custom keywords (from: Decorators for class non function properties)

2020-08-22 Thread Guido van Rossum
://mail.python.org/archives/list/python-ideas@python.org/message/3ARH7XP2BTHUWVPMH2GAIF6YDXXW3WR7/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-th

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-22 Thread Guido van Rossum
t > - wxPython, numpy, scipy, Cython > > > ___ > > Python-ideas mailing list -- python-ideas@python.org > > To unsubscribe send an email to python-ideas-le...@python.org > > https://mail.python.org/mailman3/lists/python-ideas.py

[Python-ideas] Re: still more use for pathlib.Path ....

2020-08-20 Thread Guido van Rossum
> https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/GIKHETWTXPG5CM54QV5RIHII57HUVMRM/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-20 Thread Guido van Rossum
.org > > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/BEXD7CSOWPNPBP3SEVWPPEVJJON4VJNI/ > > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- --Gu

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-20 Thread Guido van Rossum
d[0, 1, z=2]: d.__getitem__((0, 1), z=2) That may not be in the PEP, but apart from the edge cases for d[] and d[x=0] it’s exactly what I and Steven have been proposing for quite a while. —Guido -- --Guido (mobile) ___ Python-ideas mailing list -- pyth

[Python-ideas] Re: Custom keywords (from: Decorators for class non function properties)

2020-08-17 Thread Guido van Rossum
deas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/NUAHVSON3HTHNEZ7GBCI3R6XE4RSSSZP/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-17 Thread Guido van Rossum
> Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@p

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-16 Thread Guido van Rossum
On Sun, Aug 16, 2020 at 5:45 AM Steven D'Aprano wrote: > On Mon, Aug 17, 2020 at 12:32:08AM +1200, Greg Ewing wrote: > > On 16/08/20 11:49 am, Guido van Rossum wrote: > > >SEMANTICS OF NO ARGUMENTS > > >I can see two basic ways of

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-16 Thread Guido van Rossum
On Sat, Aug 15, 2020 at 10:00 PM Steven D'Aprano wrote: > On Sat, Aug 15, 2020 at 08:26:10PM -0700, Guido van Rossum wrote: > > > Are you saying that for xarray it is important to distinguish between > > `d[day=3, detector=4]` and `d[detector=4, day=3]`? If we just passed th

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-15 Thread Guido van Rossum
that for xarray it is important to distinguish between `d[day=3, detector=4]` and `d[detector=4, day=3]`? If we just passed the keyword args to `__getitem__` as an extra `**kwds` argument (which preserves order, since Python 3.6 at least), that should work, right? If not, can you clarify? --

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-15 Thread Guido van Rossum
quot; is a naughty term. (I find "runtime use of annotations" much naughtier. :-) -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> __

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-15 Thread Guido van Rossum
es based on that. FWIW in my example I sorted the keywords, so that `d[x=1, y=2]` and `d[y=2, x=1]` construct the same internal key. But for some use cases it might be better if these constructed *different* internal keys. For example, Caleb's Struct class, when used to construct a dataclass, woul

[Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar

2020-08-15 Thread Guido van Rossum
can already do with a class definition and annotations). And without static checking this isn't going to be very popular. If and when we have `__getitem__` with keyword args we can start thinking about how to best leverage it in type annotations -- I would assume that describing axes of objects like

[Python-ideas] Re: basic matrix object

2020-08-13 Thread Guido van Rossum
ition, addition, linear problem solving, determinant.") On Thu, Aug 13, 2020 at 9:04 PM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Guido van Rossum writes: > > > I was going to say that such a matrix module would be better of in > > PyPI, but

[Python-ideas] Re: basic matrix object

2020-08-13 Thread Guido van Rossum
d an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/FARJRNHNLNGRVJA3ITSUSAJCXOUUYKA2/ > Code of Conduct: http://python.or

[Python-ideas] Re: use type hints and slices to specify a valid numerical range, example: `Angle = int[0:361]`

2020-08-08 Thread Guido van Rossum
t behavior would still need to be defined. > > > --- > Ricky. > > "I've never met a Kentucky man who wasn't either thinking about going home > or actually going home." - Happy Chandler > > ___ > Python-ideas mailing

[Python-ideas] Re: Package kwkey and PEP 472 -- Support for indexing with keyword arguments

2020-08-07 Thread Guido van Rossum
On Fri, Aug 7, 2020 at 6:02 PM Greg Ewing wrote: > On 4/08/20 9:12 am, Guido van Rossum wrote: > > then presumably calling `c[1, index=2]` would just be an error (since it > > would be like attempting to call the method with two values for the > > `index` argument), >

[Python-ideas] Re: Inline Try-Except Clause

2020-08-07 Thread Guido van Rossum
On Fri, Aug 7, 2020 at 10:44 AM Rob Cliffe wrote: > > On 07/08/2020 16:58, Guido van Rossum wrote: > > On Fri, Aug 7, 2020 at 8:15 AM David Mertz wrote: > >> I think getting Guido on board would be a huge step. Python has added >> quite a bit of new syntax si

[Python-ideas] Re: Inline Try-Except Clause

2020-08-07 Thread Guido van Rossum
On Fri, Aug 7, 2020 at 8:15 AM David Mertz wrote: > I think getting Guido on board would be a huge step. Python has added > quite a bit of new syntax since 2014, and Guido himself is currently > advocating another new big change (pattern matching). His opinion may have > shif

[Python-ideas] Re: Decorators for class non function properties

2020-08-06 Thread Guido van Rossum
Maybe I’m lacking context, but I don’t understand the proposal. Can you explain the semantics and syntax you have in mind in more detail? How do you get from the first example (@my_property etc.) to the second (def name, def set_name)? —Guido On Thu, Aug 6, 2020 at 01:13 wrote: > I th

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-08-06 Thread Guido van Rossum
how it ends. (However, it *would* be hacky to vary based on whether a statement was followed by a certain other statement, as that would require going “up” in the AST.) —Guido -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To u

[Python-ideas] Re: Decorators for class non function properties

2020-08-05 Thread Guido van Rossum
is includes making up your own dunders), which means that technically the implementation could do whatever it wants -- but since this is Python we probably want to accept that it's called for every attribute, whether it smells like a descriptor or not, and it would be nice to fix the docs.

[Python-ideas] Re: Decorators for class non function properties

2020-08-05 Thread Guido van Rossum
On Wed, Aug 5, 2020 at 6:42 PM Steven D'Aprano wrote: > On Wed, Aug 05, 2020 at 06:15:22PM -0700, Guido van Rossum wrote: > > On Wed, Aug 5, 2020 at 5:55 PM Steven D'Aprano > wrote: > > > > That require two different rules for decorators: > > > > > > @

[Python-ideas] Re: Decorators for class non function properties

2020-08-05 Thread Guido van Rossum
: if the decorator raises, the name remains unbound.) > @decorator over a binding `target = expression`: > > - bind `target = decorator("target", expression)` > > So we're adding significant complexity to the concept of "decorator". > (That said, I'm not a

[Python-ideas] Re: Introduce a boundary parameter for typing.get_type_hints when used with a class object

2020-08-05 Thread Guido van Rossum
On Wed, Aug 5, 2020 at 12:25 AM Dominik Vilsmeier wrote: > On 04.08.20 22:05, Guido van Rossum wrote: > > Maybe get-type-hints can be refactored to make writing such a function > simpler. IIRC the part that takes a single annotation and evaluates it is a > private function. &g

[Python-ideas] Re: Introduce a boundary parameter for typing.get_type_hints when used with a class object

2020-08-04 Thread Guido van Rossum
essage/T6K4DWENPM7LYXSDVYQYDVFEVBMA5K3L/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https:

[Python-ideas] Re: Package kwkey and PEP 472 -- Support for indexing with keyword arguments

2020-08-03 Thread Guido van Rossum
On Mon, Aug 3, 2020 at 2:35 PM Todd wrote: > On Mon, Aug 3, 2020, 17:13 Guido van Rossum wrote: > >> On Mon, Aug 3, 2020 at 1:49 PM Christopher Barker >> wrote: >> >>> >>> Yes, that would be correct. However, the function could instead be >>>

[Python-ideas] Re: Package kwkey and PEP 472 -- Support for indexing with keyword arguments

2020-08-03 Thread Guido van Rossum
class C: def __getitem__(self, index): ... c = C() then presumably calling `c[1, index=2]` would just be an error (since it would be like attempting to call the method with two values for the `index` argument), and ditto for `c[1, 2, 3, index=4]`. The only odd case might be `c[index=

[Python-ideas] Re: Package kwkey and PEP 472 -- Support for indexing with keyword arguments

2020-08-03 Thread Guido van Rossum
t; >> If you're interested, please do try it out. >> >> IN MORE DETAIL: >> >> On 3 May 2020, Andras Tontas reopened discussion of the PEP. This PEP was >> created in June 2014, and closed in March 2019, due to lack of interest. >> See: https://mail.python.org/pipe

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-08-01 Thread Guido van Rossum
: > On Fri, Jul 31, 2020 at 7:34 AM Guido van Rossum wrote: > >> So maybe we need to add dict.ordered() which returns a view on the items >> that is a Sequence rather than a set? Or ordereditems(), orderedkeys() and >> orderedvalues()? >> > > I'm still

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-31 Thread Guido van Rossum
On Fri, Jul 31, 2020 at 7:59 PM Steven D'Aprano wrote: > On Fri, Jul 31, 2020 at 04:08:43PM -0700, Guido van Rossum wrote: > [...] > > I'm guessing that indexing by 0, if it were possible, would be a > convenient > > idiom to implement the "first item" op

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-31 Thread Guido van Rossum
. Another solution could be to make dict.ordered() fail if there are deleted keys. But that's not a great experience either. All in all I retract this idea. On Fri, Jul 31, 2020 at 5:31 PM Stestagg wrote: > On Sat, 1 Aug 2020 at 00:32, Guido van Rossum wrote: > >> If true this wou

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-31 Thread Guido van Rossum
Cs. I don't want to get into a similar situation with Set and Sequence, ever. And even though currently they *don't* have overlapping operations, the concrete types `list` and `set` *do* run into this kind of thing for comparison operators -- lists (and tuples) compare itemwise until a difference is foun

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-31 Thread Guido van Rossum
be useful -- if it's infrequently, Chris B's own solution using islice() on the items() view looked pretty decent to me, and not that hard to come up with for someone who made it that far. For the former I expect that sooner or later someone will write a PEP and it will be accepted (assuming the PEP doe

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-31 Thread Guido van Rossum
gt; >> ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-30 Thread Guido van Rossum
than is usually expected for an > attribute access. Also for compatibility (even if imperfect) with Python 2. It’s water over the dam now. —Guido -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Guido van Rossum
On Wed, Jul 29, 2020 at 07:01 Mathew Elman wrote: > > > On Wed, 29 Jul 2020 at 14:42, Guido van Rossum wrote: > >> On Wed, Jul 29, 2020 at 02:51 Mathew Elman >> wrote: >> >>> >>> . >>> >>>> If it *is* useful, it occurs to

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Guido van Rossum
> > > *If* you want tou propose clearer syntax for this, please extend the loop >> syntax, not the ‘if’ syntax. So, ‘case ... zero’ makes more sense than ‘if >> [not] break’. >> > >> —Guido >> > > So I understand, does this mean that any extended syntax

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-28 Thread Guido van Rossum
keywords”. *If* you want tou propose clearer syntax for this, please extend the loop syntax, not the ‘if’ syntax. So, ‘case ... zero’ makes more sense than ‘if [not] break’. —Guido On Tue, Jul 28, 2020 at 03:26 Jonathan Fine wrote: > Hi Rob > > You wrote: > > So: You're asking th

[Python-ideas] Re: Alternative syntax for Callable type-hinting

2020-07-28 Thread Guido van Rossum
pass > Why not just ‘(int, dict) -> None’? Do you think this is more intuitive? Is it viable? > Definitively more intuitive. With the new PEG parser it *may* be viable. However it may make it harder in the future to introduce ‘(x, y) -> x+y’ as a shorthand for

[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-26 Thread Guido van Rossum
ved at >> https://mail.python.org/archives/list/python-ideas@python.org/message/MLRFS6RO7WF2UAEOS4YMH2FXRQHJUGWU/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > ___ > Python-ideas mailing list -

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-07-25 Thread Guido van Rossum
interesting idea. It has always vaguely bothered me that `*args` gives a tuple while `**kwds` gives a dict. Unfortunately it's impossible to change without breaking tons of existing code, since things like `kwds.pop("something")` have become a pretty standard idiom to use it. -- --Guido

[Python-ideas] Re: Faster object representation for UIs

2020-07-24 Thread Guido van Rossum
eas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/KVAZJCNLO7N7DHGGTV6FYPRDKKUP7

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-22 Thread Guido van Rossum
Did you study PEP 416 (frozendict) and PEP 603 (frozenmap)? -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-wo

[Python-ideas] Re: Experimenting with dict performance, and an immutable dict

2020-07-21 Thread Guido van Rossum
ct if its content does >> not change. >> ___ >> Python-ideas mailing list -- python-ideas@python.org >> To unsubscribe send an email to python-ideas-le...@python.org >> https://mail.python.org/mailman3/lists/python-ideas.python.org/ >>

[Python-ideas] Re: add !p to pprint.pformat() in str.format() an f-strings

2020-07-21 Thread Guido van Rossum
can’t extend it by adding a special method to a class — you have to subclass the PrettyPrinter class. All in all I don’t think this is a direction we should take. — Guido -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-21 Thread Guido van Rossum
ps://mail.python.org/archives/list/python-ideas@python.org/message/G7N7WV5C6JKLIFAA5NGUXW7VEH4CMRKT/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-21 Thread Guido van Rossum
.org/mailman3/lists/python-ideas.python.org/ > > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/VSQO7A6K2SA7KI25U25CHROPEHCZFEG2/ > > Code of Conduct: http://python.org/psf/codeofconduct/ > > > > -- > Kind regar

[Python-ideas] Re: Simplifying functions syntax

2020-07-20 Thread Guido van Rossum
t;What's the difference between def and fun? > Which should I use?", doesn't make life easier for teachers. > > > -- > Steven > _______ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...

[Python-ideas] Re: isolating user allocations

2020-07-20 Thread Guido van Rossum
allocations and system allocations making sense. --Guido On Mon, Jul 20, 2020 at 7:25 PM Wenjun Huang wrote: > Hi Guido, > > Thank you for bearing with me. I wasn't trying to say you guys are mean > btw. > > I thought that the interpreter might allocate some memory for its ow

[Python-ideas] Re: isolating user allocations

2020-07-20 Thread Guido van Rossum
3 is most likely "no" due to the > costs, but it would be nice if someone could weigh in on this part. Maybe > there's some workaround. > If you were asking me to weigh in *now* I'd say "no", if only because you haven't explained the reason why this is needed. And if you ha

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-20 Thread Guido van Rossum
Also, let me be clear that this feature will never be added to the language. On Mon, Jul 20, 2020 at 07:36 Guido van Rossum wrote: > On Mon, Jul 20, 2020 at 03:22 Jonathan Fine wrote: > >> This is a continuation of my previous post to this thread. >> >> Python's FO

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-20 Thread Guido van Rossum
ond said so). I invented it without awareness of prior art, by reasoning about the similarity between IF and WHILE (FOR followed from WHILE). —Guido -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: isolating user allocations

2020-07-19 Thread Guido van Rossum
il.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/HJQW2MWFP5AUWTRD5N2TVQWAIKIDFNJW/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile) _

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-18 Thread Guido van Rossum
On Sat, Jul 18, 2020 at 9:11 PM Christopher Barker wrote: > > > On Sat, Jul 18, 2020 at 1:43 PM Guido van Rossum wrote: > >> Yes please. >> > > Yes to what, exactly? > > -CHB > > FWIW, IIRC the “bundle values in a single parameter” predates the demise

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-18 Thread Guido van Rossum
; > > -- > Steven > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message ar

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-16 Thread Guido van Rossum
020 at 11:09:42PM -0700, Caleb Donovick wrote: > > > I have wanted this and suggested it before for use with typing. > > Was Guido interested or did he reject the idea? > > > -- > Steven > ___ > Python-ideas mailing list -- pyth

[Python-ideas] Re: Missing link to git repo on the “Source code” page

2020-07-16 Thread Guido van Rossum
Hello Hans, This list is more for ideas related to Python the language. For the website, each page on python.org has a link at the bottom to the tracker where you can submit requests for improvements and PRs for the website itself. —Guido On Thu, Jul 16, 2020 at 04:31 Hans Ginzel wrote

[Python-ideas] Re: Add random.choice_iter for randomly selecting from an arbitrary iterable

2020-07-13 Thread Guido van Rossum
as well. —Guido On Mon, Jul 13, 2020 at 05:40 David Mertz wrote: > If we get this function (which I would like), the version with k items > (default 1) is much better. Some iterators cannot be repeated at all, so > not only is it slower to call multiple times if you need k>1, it's

[Python-ideas] Re: Add __eq__ to colletions.abc.Sequence ?

2020-06-30 Thread Guido van Rossum
thon.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/BZTYVERLYDWPMW2QKSMDWXRRL3DUBSDC/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* &

[Python-ideas] Re: Escapes inside curly braces in f-strings

2020-06-30 Thread Guido van Rossum
# "\xDE\xAD\xBE\xEF" > > > > This could work in f-strings and bytes as well. I think this might be of > > use for people who do a lot of work with binary file formats and hex > > escapes. > > > > I think this is backwards compatible t

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-06-27 Thread Guido van Rossum
python-ideas@python.org/message/LLK3EQ3QWNDB54SEBKJ4XEV4LXP5HVJS/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le

[Python-ideas] Re: Amend PEP-8 to require clear, understandable comments instead of Strunk & White Standard English comments

2020-06-26 Thread Guido van Rossum
mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/mes

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Guido van Rossum
rently stops at the first matching block it comes > to, not the best match out of all blocks. This is meant to make it easier > to understand the “flow” of the statement, but it might be preferable to > execute the block associated with the best match, though this would >

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Guido van Rossum
I like where this is going. It would be nice if certain constants could also be loaded from RO memory. On Mon, Jun 22, 2020 at 00:16 Inada Naoki wrote: > On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum > wrote: > > > > > > I believe this was what Greg Stein's idea

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-21 Thread Guido van Rossum
On Sun, Jun 21, 2020 at 02:53 M.-A. Lemburg wrote: > On 21.06.2020 01:47, Guido van Rossum wrote: > > Hm, I remember Greg's free threading too, but that's not the idea I was > > trying to recall this time. There really was something about bytecode > > objects being lo

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-20 Thread Guido van Rossum
worked out to the point where we could benchmark. On Sat, Jun 20, 2020 at 4:57 AM Jonathan Fine wrote: > Hi All > > Guido wrote: > > I remember vaguely that about two decades ago Greg Stein hatched an idea >> for code objects loaded from a read-only segment in shared lib

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-19 Thread Guido van Rossum
for a layout of the code object as well. But the idea was never consummated, and I think there were unsolved problems regarding reference counts and constants incorporated in the code object. The objectives were the same as the subject line of this thread, and I believe so were the objections. -- --Guido

<    1   2   3   4   5   6   7   8   9   >