Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Paul Moore
On 29 October 2016 at 07:21, Nick Coghlan wrote: > A short-circuiting if-else protocol for arbitrary "THEN if COND else > ELSE" expressions could then look like this: > > _condition = COND > if _condition: > _then = THEN > if hasattr(_condition, "__then__"): > r

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Steven D'Aprano
On Sat, Oct 29, 2016 at 03:03:22PM +1000, Nick Coghlan wrote: > On 29 October 2016 at 01:46, Ryan Gonzalez wrote: > > On Oct 28, 2016 3:30 AM, "Nick Coghlan" wrote: > >> *snip* > >> 4. Do we collectively agree that "?then" and "?else" would be > >> reasonable spellings for such operators? > > > >

Re: [Python-ideas] Null coalescing operator

2016-10-29 Thread Paul Moore
On 29 October 2016 at 07:30, Steven D'Aprano wrote: > So even though I *want* to use non-ASCI operators, I have to admit that > I *can't* realistically use non-ASCII operators. Not yet. Personally, I'm not even sure I want non-ASCII operators until non-ASCII characters are common, and used withou

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Steven D'Aprano
On Sat, Oct 29, 2016 at 02:52:42PM +1000, Nick Coghlan wrote: > On 29 October 2016 at 04:08, Mark Dickinson wrote: > > On Fri, Oct 28, 2016 at 9:30 AM, Nick Coghlan wrote: > >> [...] the current practicises of: > >> > >> * obj is not None (many different use cases) > >> * obj is not Ellipsis (in

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Steven D'Aprano
On Fri, Oct 28, 2016 at 06:30:05PM +1000, Nick Coghlan wrote: [...] > 1. Do we collectively agree that "existence checking" is a useful > general concept that exists in software development and is distinct > from the concept of "truth checking"? Not speaking for "we", only for myself: of course.

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-10-29 Thread Nick Timkovich
>From that page: > User-defined literals are basically normal function calls with a fancy > syntax. [...] While user defined literals look very neat, they are not much > more than syntactic sugar. There is not much difference between defining > and calling a literal operator with "foo"_bar and doi

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Ryan Birmingham
I certainly like the concept, but I worry that use of __exists__() could generalize it a bit beyond what you're intending in practice. It seems like this should only check if an object exists, and that adding the magic method would only lead to confusion. -Ryan Birmingham On 28 October 2016 at 0

Re: [Python-ideas] Deterministic iterator cleanup

2016-10-29 Thread Neil Girdhar
On Tuesday, October 25, 2016 at 6:26:17 PM UTC-4, Nathaniel Smith wrote: > > On Sat, Oct 22, 2016 at 9:02 AM, Nick Coghlan > wrote: > > On 20 October 2016 at 07:02, Nathaniel Smith > wrote: > >> The first change is to replace the outer for loop with a while/pop > >> loop, so that if an excep

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Ryan Gonzalez
On Oct 28, 2016 3:30 AM, "Nick Coghlan" wrote: > *snip* > > 1. Do we collectively agree that "existence checking" is a useful > general concept that exists in software development and is distinct > from the concept of "truth checking"? I'd hope so! > 2. Do we collectively agree that the Python e

Re: [Python-ideas] Null coalescing operator

2016-10-29 Thread Stephen J. Turnbull
Steven d'Aprano writes: > I think you mean WHITE SQUARE? At least, I can not see any "OPEN > SQUARE" code point in Unicode, and the character you use below □ > is called WHITE SQUARE. You're right, I just used a common Japanese name for it. I even checked the table to make sure it was BMP but

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-10-29 Thread MRAB
On 2016-10-29 17:43, Nick Timkovich wrote: [snip] Also, for discussion, remember to make the distinction between 'units' (amps, meters, seconds) and 'prefixes' (micro, milli, kilo, mega). Right away from comments, it seems 1_m could look like 1 meter to some, or 0.001 to others. Typically when I

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-10-29 Thread Todd
On Sat, Oct 29, 2016 at 12:43 PM, Nick Timkovich wrote: > From that page: > >> User-defined literals are basically normal function calls with a fancy >> syntax. [...] While user defined literals look very neat, they are not much >> more than syntactic sugar. There is not much difference between d

Re: [Python-ideas] Null coalescing operator

2016-10-29 Thread Paul Moore
On 29 October 2016 at 18:19, Stephen J. Turnbull wrote: >> For better or worse, it may be emoji that drive that change ;-) > > I suspect that the 100 million or so Chinese, Japanese, Korean, and > Indian programmers who have had systems that have no trouble > whatsoever handling non-ASCII for as l

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-10-29 Thread Nick Timkovich
Ah, always mess up micro = 6/9 until I think about it for half a second. Maybe a "n" suffix could have saved me there ;) For "long" numbers there's the new _ so you can say 0.000_000_1 if you so preferred for 0.1 micro (I generally see _ as more useful for high-precison numbers with more non-zero d

Re: [Python-ideas] Null coalescing operator

2016-10-29 Thread Mikhail V
On 29 October 2016 at 18:19, Stephen J. Turnbull wrote: >> For better or worse, it may be emoji that drive that change ;-) >> >> I suspect that the 100 million or so Chinese, Japanese, Korean, and >> Indian programmers who have had systems that have no trouble >> whatsoever handling non-ASCII for

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Nick Coghlan
On 29 October 2016 at 21:44, Steven D'Aprano wrote: > On Fri, Oct 28, 2016 at 06:30:05PM +1000, Nick Coghlan wrote: > > [...] >> 1. Do we collectively agree that "existence checking" is a useful >> general concept that exists in software development and is distinct >> from the concept of "truth ch

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Stephan Hoyer
On Sat, Oct 29, 2016 at 3:53 AM, Steven D'Aprano wrote: > Hmmm. I see your point, but honestly, None *is* special. Even for > special objects, None is even more special. As a contributor to and user of many numerical computing libraries in Python (e.g., NumPy, pandas, Dask, TensorFlow) I also a