[Python-ideas] Re: Add a replace method to tuples

2022-03-17 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Thu, Mar 17, 2022 at 01:21:24AM +0900, Stephen J. Turnbull wrote: > > > MRAB writes: > > > > > I'm wondering whether an alterative could be a function for splicing > > > sequences such as lists and tuples which would avoid the need to create > > > and then

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Chris Angelico
On Fri, 18 Mar 2022 at 00:31, David Mertz, Ph.D. wrote: > > I just do this myself in my text editor (vim): > > > But this is just cosmetic because I like to look at it this way. The actual > file on disk contains `set()`, `<=`, `in`, `not in` and wouldn't be a problem > for anyone without the s

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread David Mertz, Ph.D.
I just do this myself in my text editor (vim): [image: sets-py.png] But this is just cosmetic because I like to look at it this way. The actual file on disk contains `set()`, `<=`, `in`, `not in` and wouldn't be a problem for anyone without the same fonts installed, or require anyone to know odd

[Python-ideas] Re: Add a replace method to tuples

2022-03-17 Thread Steven D'Aprano
On Thu, Mar 17, 2022 at 08:38:19AM -0400, Ricky Teachey wrote: > Not a pro or con just an observation: since dictionaries are ordered now > people would also (somewhat reasonably, imo) want to be able to splice > them, too. Dicts are not sequences. They might preserve insertion order, but that i

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Chris Angelico
On Thu, 17 Mar 2022 at 23:19, Stéfane Fermigier wrote: > > The “correct” (according to Bourbaki) mathematical notation for an empty set > is “∅" (aka Unicode U+2205, or HTML ∅) > > Some time ago, for a project which had a lot of empty sets, I tried to use > this symbol as a short hand for set().

[Python-ideas] Re: Add a replace method to tuples

2022-03-17 Thread Ricky Teachey
On Thu, Mar 17, 2022, 5:23 AM Steven D'Aprano wrote: On Thu, Mar 17, 2022 at 01:21:24AM +0900, Stephen J. Turnbull wrote: > MRAB writes: > > > I'm wondering whether an alterative could be a function for splicing > > sequences such as lists and tuples which would avoid the need to create > > a

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Michael Smith
Hmm, I think the idea of the mathematical symbol is interesting, but I think users are more interested in constructing a new, eventually-not-empty set, than referencing the empty set. Semantically, I don't know if ∅() is satisfying. On Thu, Mar 17, 2022 at 08:19 Stéfane Fermigier wrote: > The “

[Python-ideas] Re: Add a replace method to tuples

2022-03-17 Thread dn
On 17/03/2022 05.21, Stephen J. Turnbull wrote: > MRAB writes: > > > I'm wondering whether an alterative could be a function for splicing > > sequences such as lists and tuples which would avoid the need to create > > and then destroy intermediate sequences: > > > > splice(alist, i, 1

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Stéfane Fermigier
The “correct” (according to Bourbaki) mathematical notation for an empty set is “∅" (aka Unicode U+2205, or HTML ∅) Some time ago, for a project which had a lot of empty sets, I tried to use this symbol as a short hand for set(). But: >>> ⦰ = set() File "", line 1 ⦰ = set() ^ SyntaxErr

[Python-ideas] Re: An unambiguous way of initializing an empty set and dictionary

2022-03-17 Thread Serhiy Storchaka
14.03.22 15:07, Joao S. O. Bueno пише: - but what about keeping what exists and adding {,}  for an empty set? (it is not that unlike the one-element tuple, which already exists) If you want to create an empty set without using any identifier, use {*()}. The advantage is that it works in old Py

[Python-ideas] Re: Add a replace method to tuples

2022-03-17 Thread Steven D'Aprano
On Thu, Mar 17, 2022 at 01:21:24AM +0900, Stephen J. Turnbull wrote: > MRAB writes: > > > I'm wondering whether an alterative could be a function for splicing > > sequences such as lists and tuples which would avoid the need to create > > and then destroy intermediate sequences: > > > >