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

2020-06-29 Thread Rob Cliffe via Python-ideas
On 29/06/2020 15:29, Mikhail V wrote: Proposal: Allow standard python escapes inside curly braces in f-strings. Main point is to make clear visual distinction between text and escaped chars: # current syntax: print ("\nnewline") print ("\x0aa") # new syntax: print

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

2020-06-29 Thread Steven D'Aprano
On Tue, Jun 30, 2020 at 11:10:20AM +0900, Inada Naoki wrote: > On Mon, Jun 29, 2020 at 9:12 PM Hans Ginzel wrote: > > What are the reasons, why object dict.items() is not subscriptable – > > dict.items()[0]? > > Because dict is optimized for random access by key and iteration, but not for >

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

2020-06-29 Thread MRAB
On 2020-06-30 02:14, Steven D'Aprano wrote: [snip] Counter-proposal: hex escapes allow optional curly brackets, similar to unicode name escapes. You could even allow spaces within the braces, for grouping: # Existing: "\N{HYPHEN-MINUS}" # '-' "\x2b" # '+' # Proposed

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

2020-06-29 Thread Rob Cliffe via Python-ideas
On 29/06/2020 20:19, Rhodri James wrote: On 29/06/2020 18:42, Stestagg wrote: Several times now, I've had the need to 'just get any key/value' from a large dictionary.  I usually try first to run `var.keys()[0]` only to be told that I'm not allowed to do this, and instead have to ask python

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

2020-06-29 Thread Inada Naoki
On Mon, Jun 29, 2020 at 9:12 PM Hans Ginzel wrote: > > Tahnk you, > > On Fri, Jun 26, 2020 at 10:45:07AM -0700, Brett Cannon wrote: > >Why can't you do `tuple(dict.items())` to get your indexable pairs? > > of course, I can. > But how it is expensive/effective? > What are the reasons, why object

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

2020-06-29 Thread Steven D'Aprano
On Mon, Jun 29, 2020 at 05:29:31PM +0300, Mikhail V wrote: > Proposal: > > Allow standard python escapes inside curly braces in f-strings. > Main point is to make clear visual distinction between text and > escaped chars: There is already a clear visual distinction between text and escaped

[Python-ideas] Re: giving set.add a return value

2020-06-29 Thread Christopher Barker
On Mon, Jun 29, 2020 at 1:53 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > But if it turns out that somebody *wants* to check "2 is 2.0", > this .add_unique can serve both purposes. > can it though? (or should it?) -- the fact is that it was decided the 2 and 2.0 are

[Python-ideas] Re: Is possible some day add Uniform Function Call Syntax (UFCS) in Python like Dlang?

2020-06-29 Thread Christopher Barker
It's been said, but one more tidbit: On Sun, Jun 28, 2020 at 10:32 PM Steven D'Aprano wrote: > - the compiler doesn't know what type `a` will have; > - whether or not it has a `fun` method; > - whether or not there is a global function `fun`; > - and whether it takes an argument matching `a`. >

[Python-ideas] Re: Python GIL Thoughts

2020-06-29 Thread Stestagg
Just for clarification, I assume you meant ‘per-interpreter’ there, not ‘Perl-interpreter’ which would be a somewhat more interesting option Steve On Mon, 29 Jun 2020 at 21:48, Brett Cannon wrote: > It's a discussion issue. PEP 554 is trying to focus on the API of > subinterpreters and

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

2020-06-29 Thread Joao S. O. Bueno
If you need custom sort-orders and slicing for dicts, I've implemented a b-tree backed mapping that can do just that a couple weeks ago - you are welcome to use it: https://github.com/jsbueno/extradict/blob/80817e75eabdde5583aa828c04beae6a20d3c4f7/extradict/binary_tree_dict.py#L354 (just "pip

[Python-ideas] Re: Python GIL Thoughts

2020-06-29 Thread Brett Cannon
It's a discussion issue. PEP 554 is trying to focus on the API of subinterpreters and doesn't want to distract from that by bringing the GIL into it. That being said, the general expectation from everyone involved is there will be a perl-interpreter GIL. On Sat, Jun 27, 2020 at 10:31 AM Denis

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

2020-06-29 Thread Jonathan Crall
FWIW I'm +1 on `d.keys()[i]`, `d.values()[i]`, `d.items()[i]`. I don't see any major issue with adding a __getitem__ to the view classes. I think it's a great idea, and it would make my life easier and would replace the primary use case where I currently use `ubelt.peek

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

2020-06-29 Thread Joao S. O. Bueno
On Mon, 29 Jun 2020 at 17:03, Joao S. O. Bueno wrote: > If you need custom sort-orders and slicing for dicts, I've implemented > a b-tree backed mapping that can do just that a couple weeks ago - > you are welcome to use it: > >

[Python-ideas] Re: Python JIT Compilation Thoughts

2020-06-29 Thread Brett Cannon
On Mon, Jun 29, 2020 at 2:50 AM wrote: > Ned Batchelder wrote: > > On 5/25/20 6:02 AM, redrad...@gmail.com wrote: > > > Hi all, > > > I do not know maybe it was already discussed ... > > > It's been extensively discussed and attempted. > > > but the toolchain like LLVM is very mature and it can

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

2020-06-29 Thread Rhodri James
On 29/06/2020 18:42, Stestagg wrote: Several times now, I've had the need to 'just get any key/value' from a large dictionary. I usually try first to run `var.keys()[0]` only to be told that I'm not allowed to do this, and instead have to ask python to make a copy of this datastructure with a

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

2020-06-29 Thread Christopher Barker
On Mon, Jun 29, 2020 at 11:57 AM Stestagg wrote: > I'm quite supportive (+1) of the proposal to add numeric indexing to the > 'dict_*' views. > > Given that dictionaries are now ordered, it seems reasonable to look-up, > for example, keys by index, > My first thought was no -- even though dicts

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

2020-06-29 Thread Eric V. Smith
The reason backslashes don't currently work is because of how they'd interact with string parsing. I don't think this will change until we move f-string parsing into the grammar itself, instead of happening as a post-processing step in ast.c. See bpo-33754 for one example of this. There have

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

2020-06-29 Thread Stestagg
I'm quite supportive (+1) of the proposal to add numeric indexing to the 'dict_*' views. Given that dictionaries are now ordered, it seems reasonable to look-up, for example, keys by index, One simple example of where this is surprising is in the following: >>> random.choice({'a':

[Python-ideas] Lists placed into Emergency Moderation status

2020-06-29 Thread Ernest W. Durbin III
At the request of the list moderators of python-ideas and python-dev, both lists have been placed into emergency moderation mode. All new posts must be approved before landing on the list. When directed by the list moderators, this moderation will be disabled. -Ernest W. Durbin III Director of

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

2020-06-29 Thread C. Titus Brown via Python-ideas
Hi all, as a moderator of python-ideas, I’ve asked postmaster to place python-ideas into emergency moderation. (I do not have the tools to do so myself.) I’m willing to review messages individually as needed. best, —titus > On Jun 29, 2020, at 9:24 AM, Abdur-Rahmaan Janhangeer > wrote: > >

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

2020-06-29 Thread Abdur-Rahmaan Janhangeer
Threads like these are meaningless, does not provide any learning value and is nowhere near the single vs double quote thread. It opens the gap for people who are not concerned about development jump in the game shifting the focus away while nurturing a culture of thrash I mean you tend to ignore

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

2020-06-29 Thread André Roberge
Adding my voice to those that ask for such discussions be stopped ... and, if at all possible, be snipped in the bud and prevented from occurring in the future. More below. On Mon, Jun 29, 2020 at 12:51 PM Ricky Teachey wrote: > On Mon, Jun 29, 2020 at 10:51 AM Giampaolo Rodola' > wrote: > >>

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

2020-06-29 Thread Ricky Teachey
On Mon, Jun 29, 2020 at 10:51 AM Giampaolo Rodola' wrote: > > > On Mon, Jun 29, 2020 at 12:34 PM Nathaniel Smith wrote: > >> On Mon, Jun 29, 2020 at 2:31 AM Steve Holden wrote: >> > The commit message used, however, reveals implementation details of the >> change which are irrelevant to the

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

2020-06-29 Thread Keara Berlin
Hi all, I didn't mean for there to be significant differences between what I posted here versus in the commit message. Sorry for any confusion around that! Thank you for putting them both in one place here - that is helpful. Take care, Keara On Sun, Jun 28, 2020, 16:12 Paul Sokolovsky wrote:

[Python-ideas] Re: Is possible some day add Uniform Function Call Syntax (UFCS) in Python like Dlang?

2020-06-29 Thread David Mertz
A large number of topics have come up that wish to make Python more "fluent" (https://en.wikipedia.org/wiki/Fluent_interface). This is an example of the same general idea. In every single case, the goal has been almost universally rejected as opposite Python's attitude. Converting fun(a) to

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

2020-06-29 Thread Soni L.
On 2020-06-29 11:46 a.m., Giampaolo Rodola' wrote: On Mon, Jun 29, 2020 at 12:34 PM Nathaniel Smith > wrote: On Mon, Jun 29, 2020 at 2:31 AM Steve Holden mailto:st...@holdenweb.com>> wrote: > The commit message used, however, reveals implementation details

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

2020-06-29 Thread Giampaolo Rodola'
On Mon, Jun 29, 2020 at 12:34 PM Nathaniel Smith wrote: > On Mon, Jun 29, 2020 at 2:31 AM Steve Holden wrote: > > The commit message used, however, reveals implementation details of the > change which are irrelevant to the stated aim, which is making the > documentation clear and concise. Use

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

2020-06-29 Thread Mikhail V
Proposal: Allow standard python escapes inside curly braces in f-strings. Main point is to make clear visual distinction between text and escaped chars: # current syntax: print ("\nnewline") print ("\x0aa") # new syntax: print (f"{\n}newline") print (f"{\x0a}a")

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread Chris Angelico
On Tue, Jun 30, 2020 at 12:00 AM wrote: > > Steven D'Aprano wrote: > > On Mon, Jun 29, 2020 at 10:20:40AM -, redrad...@gmail.com wrote: > > > Why I want that ? > > > Okay, here are the reasons: > > > 1) Security issue, should be fixed as soon as possible without waiting > > > 2 months or 1

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread redradist
Steven D'Aprano wrote: > On Mon, Jun 29, 2020 at 10:20:40AM -, redrad...@gmail.com wrote: > > Why I want that ? > > Okay, here are the reasons: > > 1) Security issue, should be fixed as soon as possible without waiting > > 2 months or 1 year for next CPython release > > That is an excellent

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

2020-06-29 Thread Hans Ginzel
Thank you. On Fri, Jun 26, 2020 at 02:50:22PM -0300, Joao S. O. Bueno wrote: On Fri, 26 Jun 2020 at 14:30, Hans Ginzel wrote: thank you for making dict ordered. Is it planned to access key,value pair(s) by index? See https://stackoverflow.com/a/44687752/2556118 for example. Both for reading

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

2020-06-29 Thread Hans Ginzel
Tahnk you, On Fri, Jun 26, 2020 at 10:45:07AM -0700, Brett Cannon wrote: Why can't you do `tuple(dict.items())` to get your indexable pairs? of course, I can. But how it is expensive/effective? What are the reasons, why object dict.items() is not subscriptable – dict.items()[0]? Otherwise

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread Steven D'Aprano
On Mon, Jun 29, 2020 at 10:20:40AM -, redrad...@gmail.com wrote: > Why I want that ? > Okay, here are the reasons: > 1) Security issue, should be fixed as soon as possible without waiting > 2 months or 1 year for next CPython release That is an excellent argument, but is that *our*

[Python-ideas] Re: Should use of _ as an R-value be deprecated?

2020-06-29 Thread Steven D'Aprano
On Mon, Jun 29, 2020 at 02:06:30AM -0700, Neil Girdhar wrote: > Oh, I guess there's gettext… There's also the interactive interpreter, where `_` is bound to the previously evaluated object. -- Steven ___ Python-ideas mailing list --

[Python-ideas] Re: Python __main__ function

2020-06-29 Thread redradist
Chris Angelico wrote: > On Fri, May 29, 2020 at 5:25 AM Alex Hall alex.moj...@gmail.com wrote: > > > > On Thu, May 28, 2020 at 12:57 PM Paul Sokolovsky pmis...@gmail.com wrote: > > > > > And in all fairness, all good ideas already came > > to somebody else years > > ago. There's

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

2020-06-29 Thread Edwin Zimmerman
On 6/28/2020 4:10 PM, Giampaolo Rodola' wrote: > From: > https://github.com/python/peps/commit/0c6427dcec1e98ca0bd46a876a7219ee4a9347f4 > > > Instead of requiring that comments be written in Strunk & White Standard > > English, require instead that English-language comments be clear and easily

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread redradist
Steven D'Aprano wrote: > On Tue, Jun 16, 2020 at 12:41:58PM -, redrad...@gmail.com wrote: > > As long as I cannot update version of standard > > library package > > separately from CPython version - No, they are not separate creatures > > ;) > > Why would you want to? That just sounds like

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread redradist
Edwin Zimmerman wrote: > This is still true.  There are some of us that will scream very very loud if > the std > lib disappears from Python installers.  However, I think there could easily > be a way to > satisfy both parties here.  How difficult would it be to release both full > and minimal

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread redradist
Paul Moore wrote: > On Tue, 16 Jun 2020 at 11:53, Stéfane Fermigier s...@fermigier.com wrote: > > the "batteries included" argument was a huge selling > > points years ago (when Aaron Watters wrote "Internet Programming With > > Python", for > > instance) but I think the situation has changed

[Python-ideas] Re: Modularize Python library

2020-06-29 Thread redradist
Stephen J. Turnbull wrote: > Edwin Zimmerman writes: > > This is still true.  There are some of us that will > > scream very > > very loud if the std lib disappears from Python installers.  > > However, I think there could easily be a way to satisfy both > > parties here.  How difficult would it

[Python-ideas] Re: Python JIT Compilation Thoughts

2020-06-29 Thread redradist
Ned Batchelder wrote: > On 5/25/20 6:02 AM, redrad...@gmail.com wrote: > > Hi all, > > I do not know maybe it was already discussed ... > > It's been extensively discussed and attempted. > > but the toolchain like LLVM is very mature and it can > > provide the simpler JIT compilation to machine

[Python-ideas] Re: Should use of _ as an R-value be deprecated?

2020-06-29 Thread Neil Girdhar
Oh, I guess there's gettext… On Monday, June 29, 2020 at 5:04:05 AM UTC-4, Neil Girdhar wrote: > > PEP 622 proposes a special use for _: to match anything, discarding the > whatever value matches. (If I understand.) This aligns with the way _ is > conventionally used in other statements.

[Python-ideas] Should use of _ as an R-value be deprecated?

2020-06-29 Thread Neil Girdhar
PEP 622 proposes a special use for _: to match anything, discarding the whatever value matches. (If I understand.) This aligns with the way _ is conventionally used in other statements. This special use in case statements feels weird given that _ is otherwise just an ordinary variable. It

[Python-ideas] Re: giving set.add a return value

2020-06-29 Thread Stephen J. Turnbull
Bar Harel writes: > The original example of "if dict.setdefault()" is problematic as well for > the exact same reason. You can't tell if the default value was already > there in the first place. That's not a problem. In both cases if you need an object that can't possibly be there, you have