[Python-ideas] Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steve Jorgensen
Note that I'm new to this system, so I'm not sure if this will format correctly or whether I'll be able to edit it afterward to format it properly if not. Fingers crossed. Examples: import re from collections import Sequence # Equivalent of re.compile(r'b.d').search() re.compile

[Python-ideas] Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
Currently, it is not possible to use a single method name to add an item to a collection that might be a set or a list. There have been other requests for a "push" method to be a complement to "pop", so if that were added to both set and list (synonym for .add and .append) that would solve the

[Python-ideas] Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Steve Jorgensen
it would be nice to be able to use the "with" block syntax to do things like implement a builder. To do this, the with block must be able to return a final value to the surrounding context ass part of its __exit__ behavior. obj = with builder() as b: … This would be a little like what can b

[Python-ideas] Re: Why not accept lists or arbitrary iterables in str.endswith?

2019-10-13 Thread Steve Jorgensen
Those are good points, so what about a new method for this rather than an additional behavior for the existing method? After all, "explicit is better than implicit". New method names could be something like "beginswith_any" and "endswith_any", "find_any", "index_any", "count_any", …. __

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Anders Hovmöller
Could you supply some real life examples of the proposed feature? A thing to consider here is that the with block in python doesn't introduce a scope so after: with foo() as bar: a = 2 b = 3 now bar, a and b are all available in the scope. > On 13 Oct 2019, at 15:23, Steve Jorgensen w

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Anders Hovmöller
I've many times been saved from bugs by an early crash because of this inconsistency. So it's not at all clear to me why this would be a good thing. > On 13 Oct 2019, at 15:22, Steve Jorgensen wrote: > > Currently, it is not possible to use a single method name to add an item to > a collecti

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Antoine Rozo
Hello, For your last example you have the __contains__ special methods. Le dim. 13 oct. 2019 à 15:18, Steve Jorgensen a écrit : > Note that I'm new to this system, so I'm not sure if this will format > correctly or whether I'll be able to edit it afterward to format it > properly if not. Finger

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steve Jorgensen
That's neat! I did not know about __contains__. In that case, I'm really just suggesting some additional implementations of __contains__ in builtin and standard lib classes. PS: Sorry for the missing "return" in the __rin__ example. ___ Python-ideas ma

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steve Jorgensen
I see that __contains__ is not a new thing, so I'm not sure why I didn't notice it. Thanks very much for pointing it out. :) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://ma

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Steve Jorgensen
Here's a more fleshed-out example of the kind of usage I have in mind. Note that this does not require `with` to have any affect on variable scope. The object returned from the context manager's __enter__ method is all the context that is needed or wanted for this pattern. restaurant_choic

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread David Mertz
I would not want to overload plain strings' .__contains__() method to mean "has this substring OR matches this compiled regex." Besides being on a likely performance path, it's too special. And what about glob patterns, for example? Those too? But you can wrap your strings in RegexSearchableString

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread David Mertz
Why not just: with build_choices('Restaurant') as restaurant_choices : ... print(restaurant_choices) On Sun, Oct 13, 2019, 2:49 PM Steve Jorgensen wrote: > Here's a more fleshed-out example of the kind of usage I have in mind. > Note that this does not require `with` to have an

[Python-ideas] Python 4000: Have stringlike objects provide sequence views rather than being sequences

2019-10-13 Thread Steve Jorgensen
There are many cases in which it is awkward that testing whether an object is a sequence returns `True` for instances of of `str`, `bytes`, etc. This proposal is a serious breakage of backward compatibility, so would be something for Python 4.x, not 3.x. Instead of those objects _being_ sequenc

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread David Mertz
Or if the context object needs different behavior, stick the "return value" in an attribute like restaurant_choices.data. On Sun, Oct 13, 2019, 2:56 PM David Mertz wrote: > Why not just: > > with build_choices('Restaurant') as restaurant_choices : > ... > > print(restaurant_choic

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Steve Jorgensen
Ah. Now I get the key point you were making about scope — that the `as ` variable is in the surrounding scope following the execution of the `with` block. You're right. That really does already do pretty close to what I am asking for. It's just a hair short in that it requires an additional lin

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steve Jorgensen
You make an excellent point. I withdraw that from my list of proposed cases. …and that leaves only the suggestion that `type.__contains__(self, other)` could be a synonym for `isinstance(other, self)`. ___ Python-ideas mailing list -- python-ideas@pytho

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
Failing fast is good, but it is also a very common case to want to add an item to a collection regardless of whether it is set-like or sequence-like. Does the fact that the `append` and `add` methods would still exist mitigate your objection? Call `append` when expecting a list, call `add` when

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Random832
On Sun, Oct 13, 2019, at 14:51, David Mertz wrote: > I would not want to overload plain strings' .__contains__() method to > mean "has this substring OR matches this compiled regex." Besides being > on a likely performance path, it's too special. And what about glob > patterns, for example? Thos

[Python-ideas] Re: Python 4000: Have stringlike objects provide sequence views rather than being sequences

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 12:02, Steve Jorgensen wrote: > > There are many cases in which it is awkward that testing whether an object is > a sequence returns `True` for instances of of `str`, `bytes`, etc. > > This proposal is a serious breakage of backward compatibility, so would be > something fo

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 02:38, Steve Jorgensen wrote: > > Note that I'm new to this system, so I'm not sure if this will format > correctly or whether I'll be able to edit it afterward to format it properly > if not. Fingers crossed. > > Examples: >import re >from collections import Sequen

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 12:20, Steve Jorgensen wrote: > > Failing fast is good, but it is also a very common case to want to add an > item to a collection regardless of whether it is set-like or sequence-like. > > Does the fact that the `append` and `add` methods would still exist mitigate > your

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Ricky Teachey
It seems pretty trivial to create your own push utility function: APPEND = "append" ADD = "add" def push(pushable, value): try: (getattr(t:=type(pushable), APPEND, None) or getattr(t, ADD)) (pushable, value) except AttributeError: raise TypeError(f"{t.__qualname__} objec

[Python-ideas] Re: Why not accept lists or arbitrary iterables in str.endswith?

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 04:56, Steve Jorgensen wrote: > > Those are good points, so what about a new method for this rather than an > additional behavior for the existing method? After all, "explicit is better > than implicit". > > New method names could be something like "beginswith_any" and "end

[Python-ideas] Re: Python 4000: Have stringlike objects provide sequence views rather than being sequences

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 6:49 AM Andrew Barnert via Python-ideas wrote: > And finally, if you want to break strings, it’s probably worth at least > considering making UTF-8 strings first-class objects. They can’t be randomly > accessed, but with an iterable-plus API like files, with seek/tell, or

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 12:18 AM Steve Jorgensen wrote: > class BrightColorsMeta(type): > def __rin__(self, other): > other.startswith('bright ') > > class BrightColors(metaclass=BrightColorsMeta): pass > > 'red' in BrightColors # -> False > 'bright blue' in Br

[Python-ideas] Add Scalar to collections.abc with str, bytes, etc. being both Scalar and Sequence (therefore also Container)

2019-10-13 Thread Steve Jorgensen
This is a far more modest alternative to https://mail.python.org/archives/list/python-ideas@python.org/thread/ZP2OKYEH5ZQLNJDCWVF3X6AEB3VQQT6V/ and is also something that could be reasonably & easily implemented in 3.x. Add `Scalar` to `collections.abc`. The meaning of `Scalar` is that the objec

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steve Jorgensen
This isn't really the same thing as enum since it has nothing to do with numeric values. Per Andrew, however, `__contains__` actually does exactly what I was asking for. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an ema

[Python-ideas] Re: Add Scalar to collections.abc with str, bytes, etc. being both Scalar and Sequence (therefore also Container)

2019-10-13 Thread David Mertz
What would be the practical use different from immutable? It seems like tuples and frozen sets are similarly often treated as "atomic", notwithstanding being iterable like strings are. On Sun, Oct 13, 2019, 5:07 PM Steve Jorgensen wrote: > This is a far more modest alternative to > https://mail.

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
IMO, the problem with the "you can create your own" solution is that this is such a common thing that it seems like it should simply be present rather than having a vast number of applications and libraries each implementing their own unique solutions. ___

[Python-ideas] Re: Python 4000: Have stringlike objects provide sequence views rather than being sequences

2019-10-13 Thread Steve Jorgensen
Yup. I think you're absolutely right. After I posted this, I had a better idea: https://mail.python.org/archives/list/python-ideas@python.org/thread/OVP6SIOFNGGENJAJHXOS2AEUUPWSSRD2/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscrib

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
I have definitely hit this difficulty many times. The part of the code that "just puts something in the collection" doesn't need to care conceptually about the kind of collection. Taking the data back out somewhere else more often needs to worry about order, efficiency, concurrency, etc. But as I

[Python-ideas] Re: Add Scalar to collections.abc with str, bytes, etc. being both Scalar and Sequence (therefore also Container)

2019-10-13 Thread Steve Jorgensen
It is usually quite meaningful to drill down into other kinds of immutable collections. A data structure consisting of a hierarchy of tuples would be a good example of that. Besides the drill-down, cases, there are times when it is valuable to test whether a collection or a "scalar" was receive

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
I like the way you're thinking. In any case, I think there should be some standard pattern for this implemented in the standard library. Perhaps, in addition to the using registration, implement a `__push__` method convention, and then the generic function for pushing an item to a collection wo

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
David Mertz wrote: > I have definitely hit this difficulty many times. The part of the code that > "just puts something in the collection" doesn't need to care conceptually > about the kind of collection. Taking the data back out somewhere else more > often needs to worry about order, efficiency, c

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
Sorry. I meant to say "function name/signature" ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at htt

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steven D'Aprano
On Sun, Oct 13, 2019 at 07:20:29PM -, Steve Jorgensen wrote: > Failing fast is good, but it is also a very common case to want to add > an item to a collection regardless of whether it is set-like or > sequence-like. Is that correct though? To the best of my memory, I've never wanted to ad

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 14:42, David Mertz wrote: > > I have definitely hit this difficulty many times. The part of the code that > "just puts something in the collection" doesn't need to care conceptually > about the kind of collection. Taking the data back out somewhere else more > often needs t

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
Obviously my silly name was a placeholder. I don't really have an opinion about the best spelling. On Sun, Oct 13, 2019, 6:02 PM Steve Jorgensen wrote: > David Mertz wrote: > > I have definitely hit this difficulty many times. The part of the code > that > > "just puts something in the collectio

[Python-ideas] Re: Add Scalar to collections.abc with str, bytes, etc. being both Scalar and Sequence (therefore also Container)

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 8:48 AM Steve Jorgensen wrote: > > It is usually quite meaningful to drill down into other kinds of immutable > collections. A data structure consisting of a hierarchy of tuples would be a > good example of that. > > Besides the drill-down, cases, there are times when it

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steven D'Aprano
On Sun, Oct 13, 2019 at 05:42:21PM -0400, David Mertz wrote: > I have definitely hit this difficulty many times. The part of the code that > "just puts something in the collection" doesn't need to care conceptually > about the kind of collection. Taking the data back out somewhere else more > often

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Steven D'Aprano
On Sun, Oct 13, 2019 at 03:59:19PM +0200, Anders Hovmöller wrote: > A thing to consider here is that the with block in python doesn't introduce a > scope so after: > > with foo() as bar: > a = 2 > b = 3 > > now bar, a and b are all available in the scope. That's not a problem. We could

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
On Sun, Oct 13, 2019, 6:12 PM Steven D'Aprano: > Is that correct though? To the best of my memory, I've never wanted to add > an item to a list-or-set in 15 years, nor have I seen code in practice that > does so. I don't think it is "very common" Really?! I've seen it several times this week. Ma

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 14:50, Steve Jorgensen wrote: > > Perhaps, in addition to the using registration, implement a `__push__` method > convention, and then the generic function for pushing an item to a collection > would look for `__push__`, `push`, `append`, or `add` and try the first of > tho

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
On Sun, Oct 13, 2019, 6:12 PM Andrew Barnert > from functools import singledispatch > @singledispatch > def just_add_it(collection, value): > raise TypeError(blah blah) > > Now you can explicitly register methods like this: > > just_add_it.register(set, set.add) > just_

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Eric V. Smith
On 10/13/2019 5:57 PM, Steven D'Aprano wrote: On Sun, Oct 13, 2019 at 07:20:29PM -, Steve Jorgensen wrote: Failing fast is good, but it is also a very common case to want to add an item to a collection regardless of whether it is set-like or sequence-like. Is that correct though? To the b

[Python-ideas] Re: Allow with block (context manager) to return a value (e.g. to use as a builder)

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 9:39 AM Steven D'Aprano wrote: > > On Sun, Oct 13, 2019 at 03:59:19PM +0200, Anders Hovmöller wrote: > > > A thing to consider here is that the with block in python doesn't introduce > > a scope so after: > > > > with foo() as bar: > > a = 2 > > b = 3 > > > > now b

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 9:09 AM Steven D'Aprano wrote: > > On Sun, Oct 13, 2019 at 07:20:29PM -, Steve Jorgensen wrote: > > > Failing fast is good, but it is also a very common case to want to add > > an item to a collection regardless of whether it is set-like or > > sequence-like. > > Is tha

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
OK, quick search reveals some code in my actual codebase that illustrates the concept. This isn't code I was actually looking at this week, but it is in one of the company repos. def form_to_kwarg(form): """Converts the form into the kwarg used in creates and updates. If the form isn't v

[Python-ideas] Re: Add Scalar to collections.abc with str, bytes, etc. being both Scalar and Sequence (therefore also Container)

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 14:42, Steve Jorgensen wrote: > > It is usually quite meaningful to drill down into other kinds of immutable > collections. A data structure consisting of a hierarchy of tuples would be a > good example of that. Sure, sometimes it makes sense to represent a tree as a tuple

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 15:25, David Mertz wrote: > > Sort of. I proposed the spelling as .register() because single dispatch was > the obvious way to implement it. Ah, sorry; I misread that as implying that you wanted to build something like singledispatch but less flexible, rather than just want

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Greg Ewing
Steve Jorgensen wrote: IMO, the problem with the "you can create your own" solution is that this is such a common thing Can you provide some examples of use cases from the wild? If it's as common as you say, this should be easy to do. -- Greg ___ Pyt

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steve Jorgensen
Steven D'Aprano wrote: > On Sun, Oct 13, 2019 at 05:42:21PM -0400, David Mertz wrote: > > I have definitely hit this difficulty many times. The > > part of the code that > > "just puts something in the collection" doesn't need to care conceptually > > about the kind of collection. Taking the data b

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 11:26 AM Steve Jorgensen wrote: > > Steven D'Aprano wrote: > > On Sun, Oct 13, 2019 at 05:42:21PM -0400, David Mertz wrote: > > > I have definitely hit this difficulty many times. The > > > part of the code that > > > "just puts something in the collection" doesn't need to

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Steven D'Aprano
On Sun, Oct 13, 2019 at 06:41:40PM -0400, David Mertz wrote: > My real world is looking at some function in an existing codebase that > handles a nested data structure. That rules out sets, since sets aren't hashable and cannot be inserted into a set. > At some leaf I can tell I'm handling a

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Steven D'Aprano
On Sun, Oct 13, 2019 at 07:15:09PM -, Steve Jorgensen wrote: > …and that leaves only the suggestion that `type.__contains__(self, > other)` could be a synonym for `isinstance(other, self)`. We don't normally think of an instance as being an element contained by its class. We wouldn't say th

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread David Mertz
I think the real code sample I located is pretty typical. Look at that other post. On Sun, Oct 13, 2019, 9:31 PM Steven D'Aprano wrote: > Let me see if I understand your workflow: > Well... "My workflow" is "Get a bunch of code that was written years before I was at my company, and enhance it o

[Python-ideas] Re: Why not accept lists or arbitrary iterables in str.endswith?

2019-10-13 Thread Steve Jorgensen
That makes a lot of sense. I do think this seems like useful-enough functionality to wand to add, and I like the idea of using _args_ as the means of implementation. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email t

[Python-ideas] Re: Set operations with Lists

2019-10-13 Thread Steve Jorgensen
What if, instead, there was an `OrderedBag` class that acts like a `list` and supports set operations. The advantage of this is that any hidden indexing that is used to optimize the operations could be efficiently created in the object that results from the set operation during its construction

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 18:39, Steven D'Aprano wrote: > > Even when the class can be identified as equivalent to > its set of values, such as for numeric types, there are all sorts of > complexities that will only lead to confusion: > >from numbers import Real >1.0 in Real # okay, unprobl

[Python-ideas] Re: Why not accept lists or arbitrary iterables in str.endswith?

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 19:03, Steve Jorgensen wrote: > > That makes a lot of sense. When you’re replying, it really helps to quote what you’re replying to. I have no idea which of the messages in this thread you think makes sense (except that it’s probably one of the ones replying to you). Ideal

[Python-ideas] Re: Set operations with Lists

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 19:15, Steve Jorgensen wrote: > > What if, instead, there was an `OrderedBag` class that acts like a `list` and > supports set operations. > > The advantage of this is that any hidden indexing that is used to optimize > the operations could be efficiently created in the obj

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 17:25, Steve Jorgensen wrote: > > Thinking about examples, the ones that immediately come to mind are mainly > collectors — objects passed into a method to record things that will be > examined afterward by the caller. In those cases, what I'm talking about > could actually

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Andrew Barnert via Python-ideas
On Oct 13, 2019, at 15:29, Chris Angelico wrote: > > I don't often actually want to add to list-or-set, but I do sometimes > have half-written code using one or the other, and then a future > design constraint makes me rethink my choice of data type. Oh, now I > have to change how I'm adding thos

[Python-ideas] Re: Additional meanings for "in" operator and ability to customize implementation

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 3:46 PM Andrew Barnert via Python-ideas wrote: > > On Oct 13, 2019, at 18:39, Steven D'Aprano wrote: > > > > Even when the class can be identified as equivalent to > > its set of values, such as for numeric types, there are all sorts of > > complexities that will only lead

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Serhiy Storchaka
14.10.19 03:47, Chris Angelico пише: Though a set.__setitem__() method might be helpful here. If you set an item to any truthy value, it is added to the set; set it to a falsy value and it will be discarded (without error if it wasn't there, so assignment in this way is idempotent). That would ma

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Richard Musil
On Mon, Oct 14, 2019 at 1:34 AM David Mertz wrote: > This put a certain thumb on the scale since I searched for .append() which > will automatically only find lists. Or maybe it's a deque. Or something > else. I don't actually know for sure (but I kinda think the programmers who > did this would

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Chris Angelico
On Mon, Oct 14, 2019 at 5:41 PM Serhiy Storchaka wrote: > > 14.10.19 03:47, Chris Angelico пише: > > Though a set.__setitem__() method might be helpful here. If you set an > > item to any truthy value, it is added to the set; set it to a falsy > > value and it will be discarded (without error if i