[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Dan Sommers
On 6/18/19 1:25 PM, Stephen J. Turnbull wrote: > Dan Sommers writes: > > > How would I "think of types as collections of their instances"? > > The canonical example of a type as a collection of instances is an > enumeration, the simplest (useful) example of which is bool = {False, > True}. And

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Franklin? Lee
On Tue, Jun 18, 2019 at 5:01 AM Emin Bugra Saral via Python-ideas wrote: > > `<:` kind of notation would look more clear, I agree. > > My proposition came after thinking the wording used in Python. > > issubclass() - is subclass? > > By definition, subclass reminds me set theory. > https://en.wik

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Brandt Bucher
If we want to avoid new operators, I think that the existing “from” keyword is also a good candidate: if A from (B, C) and A from D: ... I’m still skeptical of the value of this feature, though. Brandt > On Jun 19, 2019, at 08:56, Franklin? Lee > wrote: > > On Tue, Jun 18, 2019 at 5:01

[Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-19 Thread Andrew Barnert via Python-ideas
On Jun 18, 2019, at 12:43, nate lust wrote: > > I have been following this discussion for a long time, and coincidentally I > recently started working on a project that could make use of assignment > overloading. (As an aside it is a configuration system for a astronomical > data analysis pipe

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Chris Angelico
On Thu, Jun 20, 2019 at 2:07 AM Franklin? Lee wrote: > For example, > if (A <: B or A <: C) and A <: D: > is not much better than > if issubclass(A, (B, C)) and issubclass(A, D): > especially if you don't know what either of those mean. You can search > for issubclass, but you can't search

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Guido van Rossum
On Wed, Jun 19, 2019 at 11:27 AM Chris Angelico wrote: > On Thu, Jun 20, 2019 at 2:07 AM Franklin? Lee > wrote: > > For example, > > if (A <: B or A <: C) and A <: D: > > is not much better than > > if issubclass(A, (B, C)) and issubclass(A, D): > > especially if you don't know what eith

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Chris Angelico
On Thu, Jun 20, 2019 at 4:31 AM Guido van Rossum wrote: > > On Wed, Jun 19, 2019 at 11:27 AM Chris Angelico wrote: >> >> On Thu, Jun 20, 2019 at 2:07 AM Franklin? Lee >> wrote: >> > For example, >> > if (A <: B or A <: C) and A <: D: >> > is not much better than >> > if issubclass(A, (B,

[Python-ideas] Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in scala -- or yet another new operator?)

2019-06-19 Thread Andrew Barnert via Python-ideas
The thread on operators as first-class citizens keeps getting vague ideas about assignment overloading that wouldn't actually work, or don't even make sense. I think it's worth writing down the simplest design that would actually work, so people can see why it's not a good idea (or explain why

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

2019-06-19 Thread Soni L.
I'm parsing configs for domain filtering rules, and they come as a list. However, str.endswith requires a tuple. So I need to use str.endswith(tuple(list)). I don't know the reasoning for this, but why not just accept a list as well? ___ Python-ideas

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Jeffrey Kintscher
On 6/19/19 8:56 AM, Franklin? Lee wrote: For example, if (A <: B or A <: C) and A <: D: This expression makes makes very clear the high-level logic being used to determine the relationships between A, B, C, and D that is being checked, and I just need to lookup what <: means to understand

[Python-ideas] Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in scala -- or yet another new operator?)

2019-06-19 Thread Chris Angelico
On Thu, Jun 20, 2019 at 8:14 AM Andrew Barnert via Python-ideas wrote: > … x = y would mean this: > > try: > xval = globals()['x'] > result = xval.__iassign__(y) > except (LookupErrorr, AttributeError): > result = y > globals()['x'] = result > > ... > Notice tha

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

2019-06-19 Thread Andrew Barnert via Python-ideas
On Jun 19, 2019, at 15:28, Soni L. wrote: > > I'm parsing configs for domain filtering rules, and they come as a list. > However, str.endswith requires a tuple. So I need to use > str.endswith(tuple(list)). I don't know the reasoning for this, but why not > just accept a list as well? Strings

[Python-ideas] Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in scala -- or yet another new operator?)

2019-06-19 Thread Andrew Barnert via Python-ideas
On Jun 19, 2019, at 16:57, Chris Angelico wrote: > > On Thu, Jun 20, 2019 at 8:14 AM Andrew Barnert via Python-ideas > wrote: >> … x = y would mean this: >> >>try: >>xval = globals()['x'] >>result = xval.__iassign__(y) >>except (LookupErrorr, AttributeError): >>r

[Python-ideas] Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in scala -- or yet another new operator?)

2019-06-19 Thread Andrew Barnert via Python-ideas
On Jun 19, 2019, at 17:25, Andrew Barnert wrote: > > At least with CPython, I’m 99% sure… I forgot that I have Pythonista on my phone so I can check it instead of guessing. Make that 100% sure. :) ___ Python-ideas mailing list -- python-ideas@python.

[Python-ideas] Canceling thread in python

2019-06-19 Thread Matúš Valo
Hi All, Currently it is not possible to "kill" thread which is blocked. The rationale for this is handling situations when thread is blocked - e.g. when thread is quering DB when lock occurred on Database. In this case, the main thread has no way how to stop the blocked thread. Killing a thread

[Python-ideas] Re: Canceling thread in python

2019-06-19 Thread Ryan Gonzalez
IME in many of these cases you're better off using asyncio instead. -- Ryan https://refi64.com/ On Jun 20, 2019, 12:14 AM -0500, Matúš Valo , wrote: > Hi All, > > Currently it is not possible to "kill" thread which is blocked. The rationale > for this is handling situations when thread is blocked

[Python-ideas] help() with operators [was: Comparison operator support (>= and <=) for type]

2019-06-19 Thread Franklin? Lee
Python's own docs' search doesn't seem to recognize the <= symbol. Google does, but if one doesn't know that, then one won't try it. Google inconsistently decides when and which symbols are considered word chars, and I don't know whether the rules are even documented. Perhaps `help` should be the