[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Brendan Barnwell
On 2021-02-05 22:18, Random832 wrote: While we're on the subject of assignment expression limitations, I've occasionally wanted to write something like try: return a_dict[key] except KeyError: return (a_dict[key] := expression to construct value) You can already do that with

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Chris Angelico
On Sat, Feb 6, 2021 at 5:21 PM Random832 wrote: > > While we're on the subject of assignment expression limitations, I've > occasionally wanted to write something like > > try: > return a_dict[key] > except KeyError: > return (a_dict[key] := expression to construct value) That's what

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Random832
While we're on the subject of assignment expression limitations, I've occasionally wanted to write something like try: return a_dict[key] except KeyError: return (a_dict[key] := expression to construct value) ___ Python-ideas mailing list --

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Eryk Sun
On 2/5/21, Barry Scott wrote: >> On 5 Feb 2021, at 11:06, Inada Naoki wrote: > >> python.exe lookup pyvenv.cfg even outside of venv. >> So we can write utf8mode=1 in pyvenv.cfg even outside of venv. I don't like extending "pyvenv.cfg" with generic settings. This is a file to configure a virtual

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Christopher Barker
> I'm talking about the user's override of the system default. This is indeed a limitation, but I’m not sure that’s a bad thing. As I think I’ve said before, utf-8 mode is probably not a feature you want turned on for ALL instances of Python, even all instances for a single user. So if a user

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Chris Angelico
On Sat, Feb 6, 2021 at 6:08 AM Paul Sokolovsky wrote: > And looking back now, that seems like intentionally added accidental > gap in the language (https://en.wikipedia.org/wiki/Accidental_gap). > Similar to artificially limiting decorator syntax, which was already > un-limited. But seems,

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Paul Sokolovsky
Hello, Thanks for the reply. On Fri, 5 Feb 2021 13:32:25 -0500 Terry Reedy wrote: > On 2/5/2021 2:51 AM, Paul Sokolovsky wrote: > > > https://www.python.org/dev/peps/pep-0572/ > ... > > ((a, b) := (1, 2)) > >File "", line 1 > > SyntaxError: cannot use assignment expressions

[Python-ideas] Re: Add lazy import statement to protect legitimate circular imports from failing

2021-02-05 Thread Chris Angelico
On Sat, Feb 6, 2021 at 12:51 AM Matt del Valle wrote: > > Unfortunately, [lazy importers are] fundamentally incapable of dealing with > 'from x import y' syntax, because this is always loaded eagerly by the Python > interpreter. > This is because it's fundamentally hard. > With the

[Python-ideas] Re: Add lazy import statement to protect legitimate circular imports from failing

2021-02-05 Thread Matt del Valle
Since this hasn't actually received moderator approval yet, I'd be happy if you declined this post and let me resubmit it without those typos, since they actually deal with specifics of the proposal and could be confusing if left in. I'm super sorry, my mistake! On Fri, Feb 5, 2021 at 12:39 PM

[Python-ideas] Add lazy import statement to protect legitimate circular imports from failing

2021-02-05 Thread Matt del Valle
I have seen a lot of interest in this topic, and I think the sheer number of different lazy import implementations (generally using proxy objects for modules and then loading them when an attribute is accessed) should present pretty good evidence that this is a very desired feature, particularly

[Python-ideas] Re: Add lazy import statement to protect legitimate circular imports from failing

2021-02-05 Thread Matt del Valle
Whoops, sorry. I just realized that I mistyped the third paragraph from the bottom, it should be: > from some_library import AnotherClass # this causes * AnotherClass * to be imported from some_library/__init__.py which in turn causes the import statement on line 4 of some_library/__init__.py to

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Barry Scott
> On 5 Feb 2021, at 11:49, Inada Naoki wrote: > > On Fri, Feb 5, 2021 at 8:15 PM Barry Scott wrote: >> >>> >>> The main limitation is that users can not write config file in install >>> location when Python is installed for system, not for user. >> >> This is the problem that I was

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Inada Naoki
On Fri, Feb 5, 2021 at 8:15 PM Barry Scott wrote: > > > > > The main limitation is that users can not write config file in install > > location when Python is installed for system, not for user. > > This is the problem that I was thinking about when I proposed using > a py.ini like solution where

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Barry Scott
> On 5 Feb 2021, at 11:06, Inada Naoki wrote: > > On Fri, Feb 5, 2021 at 7:59 PM Barry Scott wrote: >> >> I'm under the impression that new users will not create a venv. >> Indeed I run a lot of python scripts outside of venv world. >> I only use venv as part of my development pipe lines.

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Inada Naoki
On Fri, Feb 5, 2021 at 7:59 PM Barry Scott wrote: > > I'm under the impression that new users will not create a venv. > Indeed I run a lot of python scripts outside of venv world. > I only use venv as part of my development pipe lines. > > I not sure that a venv cfg file would not help. > But a

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Barry Scott
> On 5 Feb 2021, at 03:11, Inada Naoki wrote: > > On Fri, Feb 5, 2021 at 6:17 AM Barry Scott wrote: >> >> Rather than reply point by point I will summarise my input. >> >> I think that utf-8 mode is a great idea. >> >> I think that an .INI file in the style that py.exe uses is better then

[Python-ideas] What's up with assignment expression and tuples?

2021-02-05 Thread Paul Sokolovsky
Hello, Everyone knows how hard to find a compelling usecase for the assignment expression operator (":=", colloquially "walrus operator"). https://www.python.org/dev/peps/pep-0572/ examples never felt compelling and we all remember the split it caused. I finally found a usecase where *not* using