[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 30, 2020, at 22:03, Steven D'Aprano wrote: > > On Mon, Mar 30, 2020 at 01:59:42PM -0700, Andrew Barnert via Python-ideas > wrote: > > [...] >> When you call getvalue() it then builds a Py_UCS4* >> representation that’s in this case 4x the size of the final string >> (since your string

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Stephen J. Turnbull
Steven D'Aprano writes: > [I]t ought to be clear from Paul's well-written and detailed post, > which carefully explains what he wants. Whose value to Python I still don't understand, because AFAICS it's something that on the one hand violates TOOWTDI and has no parallels elsewhere in the io mod

[Python-ideas] Re: Compound with .. else statement

2020-03-31 Thread Serhiy Storchaka
31.03.20 01:32, Christopher Barker пише: In case Serhiy's answer wasn't clear: context managers can be written to handle exceptions (within their context) in any way you see fit. that is: the method: | | |__exit__(||self||, exc_type, exc_value, exc_traceback):| get the exception, and informati

[Python-ideas] Re: Compound with .. else statement

2020-03-31 Thread Jimmy Thrasibule
> But if you use a context manager which silences the exception, like > contextlib.suppress() or unittest.TestCase.assertRaises(), it is easy to > do too. > > was_not_raised = False > with my_context(): >do_something_sensitive() >was_not_raised = True > if was

[Python-ideas] Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Philip Kahn
Yikes, this change is spitting out a lot of warnings on first run, and plenty in stuff that's not my code to boot. A huge number of the cases, though, seem to be "is 0" and "is 1" comparisons. Having read through the original issue I get where the SyntaxWarning is coming from, but it seems it'd be

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Chris Angelico
On Tue, Mar 31, 2020 at 11:57 PM Philip Kahn wrote: > > Yikes, this change is spitting out a lot of warnings on first run, and plenty > in stuff that's not my code to boot. > > A huge number of the cases, though, seem to be "is 0" and "is 1" comparisons. > Having read through the original issue

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Mon, Mar 30, 2020 at 10:08:06PM -0700, Guido van Rossum wrote: > > StringIO was created in order to fit code designed to a file, > > where all you want to do is capture its output and process it > > further, in the same process. > But it does that by *building a

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Nick Timkovich
> > I understand it locks in that particular implementation detail, but it > also seems unlikely that that particular optimization (int 0 and int 1 as > specific memory objects) would ever make sense to NOT be including in a > shipping implementation (future proof by practicality). > Do you explic

[Python-ideas] PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Gerrit Holl
(needs a sponsor) latest version at https://github.com/gerritholl/peps/blob/animal-friendly/pep-.rst PEP: Title: Retire animal-unfriendly language Author: Gerrit Holl Discussions-To: python-ideas@python.org Status: Draft Type: Informational Content-Type: text/x-rst Created: 01-Apr-2020

[Python-ideas] returning a namedtuple on dict.items()

2020-03-31 Thread Nadav Wexler
Hi, That is my first post here, I hope it's the right place for it. so I was using some dicts had the following code: env = dict(t for t in os.environ.items() if 'SUBSTRING' not in t[0]) and I thought: It could have really been nice if i could do: env = dict(t for t in os.environ.

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 31, 2020, at 05:59, Philip Kahn wrote: > > I understand it locks in that particular implementation detail, but it also > seems unlikely that that particular optimization (int 0 and int 1 as specific > memory objects) would ever make sense to NOT be including in a shipping > implementati

[Python-ideas] Re: returning a namedtuple on dict.items()

2020-03-31 Thread jdveiga
Nadav Wexler wrote: > Hi, > That is my first post here, I hope it's the right place for it. > so I was using some dicts had the following code: > env = dict(t for t in os.environ.items() if 'SUBSTRING' not in t[0]) > and I thought: It could have really been nice if i could do: > env

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
Dear Sir, I wish to complain in the strongest possible terms about the PEP which you have just transmitted about the inconsiderateness of spam. Many of my best friends are horned Vikings, and only a few of them are animal torturers. Yours faithfully, Brigadier Sir Andrew Barnert, OBE, retired, M

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Antoine Pitrou
Your search is incomplete, for example you failed to account for occurrences of "cheese" and "milkshake". Regards Antoine. On Tue, 31 Mar 2020 19:17:18 +0200 Gerrit Holl wrote: > (needs a sponsor) > > latest version at > https://github.com/gerritholl/peps/blob/animal-friendly/pep-.rst >

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Evpok Padding
Even if you think this is clever or funny, are you absolutely sure you needed to share it with the subscribers to this mailing list? On Tue, 31 Mar 2020 at 17:46, Andrew Barnert via Python-ideas < python-ideas@python.org> wrote: > Dear Sir, I wish to complain in the strongest possible terms about

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Serhiy Storchaka
31.03.20 20:21, Andrew Barnert via Python-ideas пише: Do you have code that you think actually _should_ be using is 1? Or code that you have to compile over and over (e.g., your deployment server doesn’t cache .pyc files, or you spawn new instances all the time without pre-built .pycs, or your

[Python-ideas] Re: returning a namedtuple on dict.items()

2020-03-31 Thread Serhiy Storchaka
31.03.20 20:15, Nadav Wexler пише: Hi, That is my first post here, I hope it's the right place for it. so I was using some dicts had the following code:         env = dict(t for t in os.environ.items() if 'SUBSTRING' not in t[0]) and I thought: It could have really been nice if i could do:

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Serhiy Storchaka
31.03.20 20:52, Antoine Pitrou пише: Your search is incomplete, for example you failed to account for occurrences of "cheese" and "milkshake". I thought palm trees are plants. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe sen

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread M.-A. Lemburg
On 3/31/2020 7:58 PM, Serhiy Storchaka wrote: > 31.03.20 20:21, Andrew Barnert via Python-ideas пише: >> Do you have code that you think actually _should_ be using is 1? Or >> code that you have to compile over and over (e.g., your deployment >> server doesn’t cache .pyc files, or you spawn new ins

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Chris Angelico
On Wed, Apr 1, 2020 at 4:19 AM Gerrit Holl wrote: > Abstract > > > Python has long used metasyntactic variables that are based on the > consumption of meat and dairy products, such as "spam", "ham", and > "eggs". > This language is not considerate to pigs or chicken and violates the > spi

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Ricky Teachey
Just in case this was not proposed in jest: How about just adding a note stipulating that if found offensive, all references to animal derived products are encouraged to be interpreted as their real or hypothetical plant-based alternatives, some of which exist today (plant based "ham", "chicken")

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Dan Sommers
On Tue, 31 Mar 2020 19:17:18 +0200 Gerrit Holl wrote: > Abstract > > Python has long used metasyntactic variables that are based on the > consumption of meat and dairy products, such as "spam", "ham", and > "eggs". > This language is not considerate to pigs or chicken and violates the

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Oleg Broytman
On Tue, Mar 31, 2020 at 09:08:50PM +0300, Serhiy Storchaka wrote: > 31.03.20 20:52, Antoine Pitrou пише: > > Your search is incomplete, for example you failed to account for > > occurrences of "cheese" and "milkshake". > > I thought palm trees are plants. Animals can fight or run, but plants

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Paul Sokolovsky
Hello, On Mon, 30 Mar 2020 13:59:42 -0700 Andrew Barnert wrote: > On Mar 30, 2020, at 13:06, Paul Sokolovsky wrote: > > > > I appreciate expressing it all concisely and clearly. Then let me > > respond here instead of the very first '"".join() rules!' reply I > > got. > > Ignoring replies d

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Paul Sokolovsky
Hello, On Mon, 30 Mar 2020 16:25:07 -0700 Christopher Barker wrote: > As others have pointed out, the OP started in a bit of an oblique > way, but it maybe come down to this: > > There are some use-cases for a mutable string type. For avoidance of doubt: nothing in my RFC has anything to do,

[Python-ideas] Re: returning a namedtuple on dict.items()

2020-03-31 Thread Nadav Wexler
that's what I assumed... thanks for the reply! :) On Tue, Mar 31, 2020 at 9:08 PM Serhiy Storchaka wrote: > 31.03.20 20:15, Nadav Wexler пише: > > Hi, > > That is my first post here, I hope it's the right place for it. > > > > so I was using some dicts had the following code: > > env =

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Mark Dickinson
> > > Proposed alternatives > = > > Keeping with the good practice of referencing sketches from Monty > Python's > Flying Circus, this PEP proposes to adopt the fruits mentioned in the > `"Self-Defence Against Fresh Fruit" sketch`_: > > * raspberry (not currently in use) > * ban

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread jdveiga
Paul Sokolovsky wrote: > Hello, > On Mon, 30 Mar 2020 16:25:07 -0700 > Christopher Barker python...@gmail.com wrote: > > As others have pointed out, the OP started in a bit > > of an oblique > > way, but it maybe come down to this: > > There are some use-cases for a mutable string type. > > For av

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 31, 2020, at 10:54, Evpok Padding wrote: > > > Even if you think this is clever or funny, are you absolutely sure you needed > to share it with the subscribers to this mailing list? Now, I’ve noticed a tendency for this thread to get rather silly. Now I do my best to keep things moving

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 31, 2020, at 12:03, Oleg Broytman wrote: > > Animals can fight or run, but plants cannot. So we must protect > plants more, not less! That’s just what the plants want you to believe. Have you ever seen how trees get on when there are no humans about? No, of course you haven’t, because it

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Paul Sokolovsky
Hello, On Mon, 30 Mar 2020 23:20:28 -0400 David Mertz wrote: > I have myself been "guilty" of using the problem style for N < 10. In > fact, I had forgotten about the optimization even, since my uses are > negligible time. I personally don't think it's a "problem style" per se. I'm using it al

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 31, 2020, at 12:06, Paul Sokolovsky wrote: I don’t know why you think being snarky helps make your case. If you make a mistake and it’s pointed out and you give a sarcastically over-enthusiastic thanks, that doesn’t change the fact that it‘s wrong, and if your rationale depends on thing

[Python-ideas] Re: Compound with .. else statement

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 31, 2020, at 03:06, Jimmy Thrasibule wrote: > >  >> >> But if you use a context manager which silences the exception, like >> contextlib.suppress() or unittest.TestCase.assertRaises(), it is easy to >> do too. >> >> was_not_raised = False >> with my_context(): >> do_so

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Paul Sokolovsky
Hello, On Tue, 31 Mar 2020 16:28:22 +1100 Steven D'Aprano wrote: > On Mon, Mar 30, 2020 at 10:08:06PM -0700, Guido van Rossum wrote: > > On Mon, Mar 30, 2020 at 10:00 PM Steven D'Aprano > > wrote: > > > > > > it’s optimized for a different use case than string building, > > > > > > It is?

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Paul Sokolovsky
Hello, On Tue, 31 Mar 2020 18:09:59 +0900 "Stephen J. Turnbull" wrote: [] > [3] Paul's "exact alias of .write() method", which can be done in 1 > line, fails because .write() doesn't return self. Thanks, Serhiy. In I stand corrected gentlemen, thanks for catching that. It's a poorman's pep,

[Python-ideas] pretty-printing in the terminal

2020-03-31 Thread Per Bothner
Inspired by the LWN article (https://lwn.net/Articles/815265/) about enhanced pretty-printing, I implemented a modified repr/displayhook that makes uses of the builtin pretty-printing of the DomTerm (https://domterm.org) terminal emulator. See this screenshot http://domterm.org/images/python-pre

[Python-ideas] Re: pretty-printing in the terminal

2020-03-31 Thread Wes Turner
"[Python-ideas] dunder methods for encoding & prettiness aware formal & informal representations" https://mail.python.org/archives/list/python-ideas@python.org/thread/OQPPJ7SNM5CZUI5RYT5R4Z6YZWMNNTZS/ discusses how pretty printing could be extended. I'll bump the thread On Tue, Mar 31, 2020, 5:54

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-31 Thread Wes Turner
Bump to CC Re: "[Python-ideas] pretty-printing in the terminal" On Sun, Mar 22, 2020, 8:53 PM Kyle Stanley wrote: > I ended up opening an issue for it at https://bugs.python.org/issue40045. > > > On Sun, Mar 22, 2020 at 8:33 PM Kyle Stanley wrote: > >> Chistopher Barker

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Matthias Bussonnier
On Tue, 31 Mar 2020 at 10:18, Gerrit Holl wrote: > the command ``cat $(find . -name '*.py') | grep -oi term | wc -l`` was used. I'm quite concern in the lack of mention of proper forms and procedure to perform experiment with domestic felines. -- Mathias

[Python-ideas] Re: returning a namedtuple on dict.items()

2020-03-31 Thread Cameron Simpson
On 31Mar2020 22:28, Nadav Wexler wrote: that's what I assumed... thanks for the reply! :) Also, there are modules to provide this kind of thing when you want it. For example, my cs.mappings module: https://pypi.org/project/cs.mappings/ has dicts_to_namedtuples() which converts an iterable

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Christopher Barker
On Tue, Mar 31, 2020 at 12:21 PM Paul Sokolovsky wrote: > Christopher Barker wrote: > For avoidance of doubt: nothing in my RFC has anything to do, or > implies, "a mutable string type". I said "there are some use cases for a mutable string type" I did not say that's what was asked for in this

[Python-ideas] Re: Compound with .. else statement

2020-03-31 Thread Christopher Barker
On Tue, Mar 31, 2020 at 2:41 AM Serhiy Storchaka wrote: > 31.03.20 01:32, Christopher Barker пише: > > In case Serhiy's answer wasn't clear: context managers can be written to > > handle exceptions (within their context) in any way you see fit. > > > > that is: the method: > > | > > | > > |__exit

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Steven D'Aprano
On Tue, Mar 31, 2020 at 07:32:11PM -, jdve...@gmail.com wrote: > If I understand you are proposing a change from StringIO `write` > method to `+=` operator. Is it right? No, that is not correct. The StringIO.write() method will not be changed or removed. The proposal is to extend the class

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Kyle Stanley
Chris Angelico wrote: > We will need a > migration plan. Unfortunately, African swallows are non-migratory, > severely impacting your proposal. Well, aren't European swallows migratory? They may not be able to carry a coconut, but certainly a migratory plan would be under their weight limit. :-)

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Chris Angelico
On Wed, Apr 1, 2020 at 12:28 PM Kyle Stanley wrote: > > Chris Angelico wrote: > > We will need a > > migration plan. Unfortunately, African swallows are non-migratory, > > severely impacting your proposal. > > Well, aren't European swallows migratory? They may not be able to carry a > coconut, bu

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Greg Ewing
On 1/04/20 7:08 am, Serhiy Storchaka wrote: 31.03.20 20:52, Antoine Pitrou пише: Your search is incomplete, for example you failed to account for occurrences of "cheese" and "milkshake". Should we deprecate the word "wheel" as well, since it's a reference to cheese? -- Greg __