[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 22:22, Soni L. wrote: > > >> >> > or maybe: >> >> > > foo = f"{from foo.bar import 'foo.txt'}" # string imports >> >> > bbar = fb"{from foo.bar import 'bar.txt'}" # bytes imports >> >> >> This version would require turning import from a statement into an >> >> >>

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Chris Angelico
On Mon, Jan 20, 2020 at 5:23 PM Soni L. wrote: > What the eff is this then? > https://docs.python.org/3/library/importlib.html#module-importlib.resources > > Because I'm pretty sure this is literally part of the existing import > machinery. Because importlib *is* the existing import machinery.

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
On Sun, Jan 19, 2020 at 8:16 PM Andrew Barnert wrote: > On Jan 19, 2020, at 15:20, Guido van Rossum wrote: > > > On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: > >> [Guido, on Pythons before 1.0.2 always printing non-None expression >> statement results] >> > Heh. That was such a

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 20:13, Soni L. wrote: > > >> On 2020-01-20 12:48 a.m., Andrew Barnert wrote: >> On Jan 19, 2020, at 15:10, Soni L. wrote: >> > > We have importlib. We have importlib.resources. We can import modules. >> > > We cannot (yet) import resources using the same-ish module import

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 15:20, Guido van Rossum wrote: > >> On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: >> [Guido, on Pythons before 1.0.2 always printing non-None expression >> statement results] >> > Heh. That was such a misfeature that I had thoroughly suppressed any >> > memory of its

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Soni L.
On 2020-01-20 12:48 a.m., Andrew Barnert wrote: On Jan 19, 2020, at 15:10, Soni L. wrote: > > We have importlib. We have importlib.resources. We can import modules. We cannot (yet) import resources using the same-ish module import machinery. First, do you know about setuptools resources?

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 15:10, Soni L. wrote: > > We have importlib. We have importlib.resources. We can import modules. We > cannot (yet) import resources using the same-ish module import machinery. First, do you know about setuptools resources? It’s not exactly what you’re looking for, but it

[Python-ideas] Re: Compound statement colon (Re: Re: Improve SyntaxError for obvious issue:)

2020-01-19 Thread Christopher Barker
note that there is a FAQ about this: https://docs.python.org/3/faq/design.html#why-are-colons-required-for-the-if-while-def-class-statements And if you google hard enough (my 30 seconds wasn't enough), I'm pretty sure you can find a description of actual usability tests (if informal) mack in the

[Python-ideas] Re: List - append

2020-01-19 Thread Christopher Barker
By the way, if anyone is actually interested in this other than for nostalgia , there have been a number of lengthy discussion on this list about "Fluent" interfaces for Python. LIke this one for instance:

[Python-ideas] Re: List - append

2020-01-19 Thread Christopher Barker
On Sun, Jan 19, 2020 at 11:59 AM Tim Peters wrote: > For a bit of history that I may have made up (heh - memory fades over > time!), as I recall, the very first Python pre-releases echoed to > stdout every non-None statement result. which is what MATLAB does, if you don't put a semi-colon at

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Soni L.
On 2020-01-19 8:49 p.m., Tener Hades wrote: > def unpack_defaults(): >   open("templates/index.html", "w").write(f"{from ganarchy.templates > import 'index.html'}") This is non-idiomatic to not only Python, but any language I've seen thus far in my career. What does this achieve which

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
On Sun, Jan 19, 2020 at 3:10 PM Tim Peters wrote: > [Guido, on Pythons before 1.0.2 always printing non-None expression > statement results] > > Heh. That was such a misfeature that I had thoroughly suppressed any > > memory of its existence. -k indeed. :-) > > I prefer to think of it as a bit

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[Guido, on Pythons before 1.0.2 always printing non-None expression statement results] > Heh. That was such a misfeature that I had thoroughly suppressed any > memory of its existence. -k indeed. :-) I prefer to think of it as a bit of genius :-) The natural desire to avoid mounds of useless

[Python-ideas] Resource imports (as strings/bytes)

2020-01-19 Thread Soni L.
We have importlib. We have importlib.resources. We can import modules. We cannot (yet) import resources using the same-ish module import machinery. It would be nice if we could. I'm thinking of something like: from foo.bar import resources "foo.txt" as foo, "bar.txt" as bar # string imports

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
Heh. That was such a misfeature that I had thoroughly suppressed any memory of its existence. -k indeed. :-) On Sun, Jan 19, 2020 at 1:33 PM Tim Peters wrote: > [Guido] > > Sounds like a hallucination or fabrication. > > Nope! Turns out my memory was right :-) > > > The behavior of `for i in

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
I should really upgrade to 1.02! % python Python 1.0.1 (Jul 15 2016) Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam >>> def f(): ... for i in range(5): i ... >>> f() 0 1 2 3 4 On Sun, Jan 19, 2020 at 4:33 PM Tim Peters wrote: > [Guido] > > Sounds like a hallucination or

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[Guido] > Sounds like a hallucination or fabrication. Nope! Turns out my memory was right :-) > The behavior of `for i in range(10): i` in the REPL exists > to this day, and list.append() never returned a value. Sure, but those weren't the claims. The claim was that the result of an

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
On Sun, Jan 19, 2020 at 3:56 PM Steven D'Aprano wrote: > > The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) > is > > popular in many programming languages, including in the sort of > > "mini-language" Pandas, within portion. > > I can't speak about Pandas, but what the OP

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 12:15, David Mertz wrote: > > In contrast, in pure Python, most of that you do is in loops over the > elements of collections. In that case is does a good job of drawing your eye > to the fact that a method is called but not assigned to anything. When I see >

[Python-ideas] Re: List - append

2020-01-19 Thread Steven D'Aprano
On Sun, Jan 19, 2020 at 02:37:14PM -0500, David Mertz wrote: > The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) is > popular in many programming languages, including in the sort of > "mini-language" Pandas, within portion. I can't speak about Pandas, but what the OP is

[Python-ideas] Re: List - append

2020-01-19 Thread Steven D'Aprano
On Sun, Jan 19, 2020 at 08:32:43AM -0800, Guido van Rossum wrote: > I'm not excited about suggesting the walrus operator when people want to > chain mutating method calls like this. It results in ugly code with way too > many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't >

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
Sounds like a hallucination or fabrication. The behavior of `for i in range(10): i` in the REPL exists to this day, and list.append() never returned a value. The only thing I'm only 90% sure of is whether the REPL always ignored None values. On Sun, Jan 19, 2020 at 11:58 AM Tim Peters wrote: >

[Python-ideas] Re: List - append

2020-01-19 Thread Tim Peters
[David Mertz ] > ... > What we get instead is a clear divide between mutating methods > on collections that (almost) always return None, and functions > like sorted() and reversed() that return copies of the underlying > collection/iterable. Of course, there are many methods that don't > have

[Python-ideas] Re: List - append

2020-01-19 Thread David Mertz
The "fluent interface" (https://en.wikipedia.org/wiki/Fluent_interface) is popular in many programming languages, including in the sort of "mini-language" Pandas, within portion. But it is definitely not Pythonic. The Wikipedia article even shows how you *could* do it in Python, but mentions that

[Python-ideas] Re: List - append

2020-01-19 Thread Siddharth Prajosh
On Sun, Jan 19, 2020 at 10:03 PM Guido van Rossum wrote: > I'm not excited about suggesting the walrus operator when people want to > chain mutating method calls like this. It results in ugly code with way too > many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't > go off

[Python-ideas] Re: List - append

2020-01-19 Thread Guido van Rossum
I'm not excited about suggesting the walrus operator when people want to chain mutating method calls like this. It results in ugly code with way too many parentheses and a distinctly un-Pythonic flavor. I hope the OP doesn't go off and infect a whole subcommunity with this idiom. On Sat, Jan 18,

[Python-ideas] Re: Compound statement colon (Re: Re: Improve SyntaxError for obvious issue:)

2020-01-19 Thread Random832
On Fri, Jan 17, 2020, at 21:32, Josh Rosenberg wrote: > The colon remains syntactically necessary in some cases, particularly > to disambiguate cases involving one-lining (no block involved). Stupid > example: If the colon is optional, what does: I was only proposing making it optional in the

[Python-ideas] Re: List - append

2020-01-19 Thread Siddharth Prajosh
On Sun, 19 Jan, 2020, 11:35 Inada Naoki, wrote: > On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh > wrote: > > > > Moreover, shouldn't it work? > > How do I add that feature in Python? > > How you can do it with warus operator. > > >>> (xs := list(range(10))).append(42) > >>> xs > [0, 1, 2,