Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 2:38 AM, Steven D'Aprano wrote: > The lack of support for the `in` operator is a major difference, but > there's also `len` (equivalent to "count the one bits"), superset > and subset testing, various in-place mutator methods, etc. Java has a > BitSet

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Fri, Dec 29, 2017 at 7:18 PM, Steven D'Aprano wrote: > Since ints don't provide a set-like interface, they aren't strictly > speaking bitsets. But in any case, nobody is stopping people from using > sets of enum values. I'm not sure what "set-like interface" you'd be

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-29 Thread Chris Angelico
On Sat, Dec 30, 2017 at 3:56 AM, Stephan Hoyer wrote: > We already have a built-in immutable set for Python. It's called frozenset. This is true, but AIUI its API is based primarily on that of the (mutable) set. If you were creating a greenfield ImmutableSet class, what would

Re: [Python-ideas] Repr of lambda

2017-12-21 Thread Chris Angelico
On Fri, Dec 22, 2017 at 9:43 AM, Chris Barker wrote: > Every python object has an object identity, and the way to get it is with > the id() function. The id is also part of the default object repr, but given > that some, but only some objects have the id in their repr, it's

Re: [Python-ideas] [Python-Dev] subprocess not escaping "^" on Windows

2018-01-07 Thread Chris Angelico
Redirecting this part of the conversation to python-ideas. On Mon, Jan 8, 2018 at 3:17 AM, Christian Tismer wrote: > As a side note: In most cases where shell=True is found, people > seem to need evaluation of the PATH variable. To my understanding, > from subprocess

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-11 Thread Chris Angelico
On Thu, Jan 11, 2018 at 7:58 PM, M.-A. Lemburg wrote: > On 11.01.2018 01:22, Nick Coghlan wrote: >> On 11 January 2018 at 05:04, M.-A. Lemburg wrote: >>> For the stdlib, I think we should stick to standards and >>> not go for spreading non-standard ones. >>> >>>

Re: [Python-ideas] make Connections iterable

2018-01-09 Thread Chris Angelico
On Tue, Jan 9, 2018 at 11:12 PM, Random832 wrote: > On Tue, Jan 9, 2018, at 05:46, Nick Coghlan wrote: >> If you view them as comparable to subprocess pipes, then it can be >> surprising that they're not iterable when using a line-oriented >> protocol. >> >> If you instead

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Chris Angelico
On Fri, Jan 26, 2018 at 7:42 PM, INADA Naoki wrote: > Hi. > > Currently, int(), str.isdigit(), str.isalnum(), etc... accepts > non-ASCII strings. > s = 123" s > '123' s.isdigit() > True print(ascii(s)) > '\uff11\uff12\uff13' int(s) > 123 > > But

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Chris Angelico
On Fri, Jan 26, 2018 at 10:17 PM, INADA Naoki wrote: >> No, because you can pass in maxchar to PyUnicode_New() and >> the implementation will take this as hint to the max code point >> used in the string. There is no check done whether maxchar >> is indeed the minimum

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-17 Thread Chris Angelico
On Thu, Jan 18, 2018 at 4:21 PM, Steve Barnes wrote: > 1. For asserts that should not be disabled we could have an always > qualifier optionally added to assert, either as "assert condition > exception always" or "assert always condition exception", that disables > the

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Chris Angelico
On Thu, Jan 25, 2018 at 3:46 AM, Thomas Güttler wrote: > I found a question and answer at Stackoverflow[1] which says > that asyncio/await is like cooperative multitasking. "Like"? It *is* a form of co-operative multitasking. > My whish is to have preemptive

Re: [Python-ideas] Why CPython is still behind in performance for some widely used patterns ?

2018-01-26 Thread Chris Angelico
On Sat, Jan 27, 2018 at 8:35 AM, Pau Freixes wrote: > def filter(rule, whatever): > if rule.x in whatever.x: > return True > > rules = get_rules() > whatevers = get_whatevers() > for rule in rules: > for whatever in whatevers: > if filter(rule,

Re: [Python-ideas] Why CPython is still behind in performance for some widely used patterns ?

2018-01-26 Thread Chris Angelico
On Sat, Jan 27, 2018 at 10:07 AM, Steven D'Aprano <st...@pearwood.info> wrote: > On Sat, Jan 27, 2018 at 09:12:29AM +1100, Chris Angelico wrote: > >> Are you sure it's the language's fault? Failing to use a better data >> type simply because some other language doesn'

Re: [Python-ideas] Logging: a more perseverent version of the StreamHandler?

2018-01-30 Thread Chris Angelico
On Wed, Jan 31, 2018 at 6:43 AM, liam marsh wrote: > Hello, and sorry for the late answer, > > > Le 29/01/2018 à 01:41, Steven D'Aprano a écrit : > > [...] > I'll comment on the email: for some reason, the implementation you > give has extraneous pipes | at the start

Re: [Python-ideas] Adding str.isascii() ?

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 12:44 AM, Victor Stinner wrote: > I like the idea of str.isdigit(ascii=True): would behave as > str.isdigit() and str.isascii(). It's easy to implement and likely to > be very efficient. I'm just not sure that it's so commonly required? > > At

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 10:15 AM, Chris Barker wrote: > I still have no ide4a why there is such resistance to this -- yes, it's a > fairly small benefit over a package no PyPi, but there is also virtually no > downside. I don't understand it either. Aside from maybe

Re: [Python-ideas] Consider generalizing Decimal to support arbitrary radix

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 10:49 AM, Neil Girdhar wrote: >> > Right, I was playing with this problem >> > >> > (https://brilliant.org/weekly-problems/2017-10-02/advanced/?problem=no-computer-needed) >> > and wanted to work in base 2. I realize it's niche, but it's not >> >

Re: [Python-ideas] Consider generalizing Decimal to support arbitrary radix

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 10:08 AM, Neil Girdhar wrote: > > On Wed, Feb 7, 2018 at 5:52 PM Steven D'Aprano wrote: >> >> - slower; >> - larger errors when converting from decimal numbers (in general); >> - larger rounding errors; >> - larger wobble; > > >

Re: [Python-ideas] Consider generalizing Decimal to support arbitrary radix

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 8:49 AM, Neil Girdhar wrote: > Arbitrary radix comes up every now and then and Decimal already has a > radix() method. It would be nice when initializing a Decimal object to be > able to specify an arbitrary radix>=2. > The radix method always

Re: [Python-ideas] Complicate str methods

2018-02-03 Thread Chris Angelico
On Sun, Feb 4, 2018 at 10:43 AM, Terry Reedy wrote: > On 2/3/2018 5:04 PM, Franklin? Lee wrote: >> s.startswith, s.endswith: >> Allow argument to be a collection of strings. > > > bool(re.match('|'.join(strings)) does exactly the proposed s.startswith, > with the advantage

Re: [Python-ideas] Easing set-up of of console python applications

2018-02-10 Thread Chris Angelico
On Sun, Feb 11, 2018 at 6:29 AM, Mario Corchero wrote: > Hello All! > > I got asked how to configure the logging stack to be able to output directly > to console using both stdout and stderr and I could not really find a great > answer as adding both as StreamHandlers will

Re: [Python-ideas] Easing set-up of of console python applications

2018-02-10 Thread Chris Angelico
On Sun, Feb 11, 2018 at 7:49 AM, Mario Corchero wrote: > The recipe as you pointed out works by logging to both (just using multiple > handlers). Yep. It's a "forking" setup. What you're proposing is a "splitting" setup, which would be a great recipe to put immediately

Re: [Python-ideas] Give ipaddresses an __index__ method

2018-02-14 Thread Chris Angelico
On Thu, Feb 15, 2018 at 11:18 AM, Steven D'Aprano wrote: > This idea is inspired by Eric Osborne's post "Extending __format__ > method in ipaddress", but I wanted to avoid derailing that thread. > > I notice what seems to be an inconsistency in the ipaddress objects: > > py>

Re: [Python-ideas] Give ipaddresses an __index__ method

2018-02-14 Thread Chris Angelico
On Thu, Feb 15, 2018 at 3:14 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Thu, Feb 15, 2018 at 11:45:46AM +1100, Chris Angelico wrote: > >> Except that this computer's IPv4 is not 3232235539, and I never want >> to enter it that way. I enter it as 192.168

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 5:24 AM, Chris Barker wrote: > On Thu, Feb 22, 2018 at 6:21 PM, Nick Coghlan wrote: >> >> > (I wonder if the discrepancy is due to some internal interface that >> > loses >> > the distinction between None and 1 before the

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 6:38 AM, Serhiy Storchaka <storch...@gmail.com> wrote: > 23.02.18 20:50, Chris Angelico пише: >> >> Ignoring backward compatibility, it ought to be possible to (ab)use a >> stride of zero for this. Calling slice.indices() on something with

Re: [Python-ideas] Internal function idea

2017-12-29 Thread Chris Angelico
On Fri, Dec 29, 2017 at 5:03 PM, Franklin? Lee <leewangzhong+pyt...@gmail.com> wrote: > On Fri, Dec 29, 2017 at 1:01 AM, Chris Angelico <ros...@gmail.com> wrote: >> On Fri, Dec 29, 2017 at 1:31 PM, Franklin? Lee >> <leewangzhong+pyt...@gmail.com> wrote: >>>

Re: [Python-ideas] Internal function idea

2017-12-28 Thread Chris Angelico
On Fri, Dec 29, 2017 at 1:31 PM, Franklin? Lee wrote: > On Thu, Dec 28, 2017 at 5:21 AM, William Rose > wrote: >> I agree with the point that it should allow builtin but the main purpose of >> it is to not allow global variables > > But

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Thu, Aug 2, 2018 at 12:04 AM, Jonathan Fine wrote: > Hi Steve > > Thank you for your reply. > > We're discussing the abstract to PEP 505, which writes > === > The "None-aware attribute access" operator ?. ("maybe dot") evaluates > the complete expression if the left hand side evaluates to a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-29 Thread Chris Angelico
On Sun, Jul 29, 2018 at 3:54 PM, Steven D'Aprano wrote: > Being an implementation detail, CPython is free to change it at any > time, without warning or notice, even in a bug-fix release. If CPython > ever gets a memory manager that can move objects around, as they can > move in Jython and

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-28 Thread Chris Angelico
On Sun, Jul 29, 2018 at 1:56 PM, Abe Dillon wrote: >> Python does not have memory locations. > > > CPython does, form the documentation on the `id` function: > >> CPython implementation detail: This is the address of the object in >> memory. Right, which is an important distinction; CPython,

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-28 Thread Chris Angelico
On Sun, Jul 29, 2018 at 6:07 AM, Abe Dillon wrote: > Yes, I thought of that and came to the same conclusion. It's my > understanding that None may not be an actual object, but a special memory > location. I'm not sure though and didn't look it up. Python does not have memory locations. None *is*

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-29 Thread Chris Angelico
On Sun, Jul 29, 2018 at 5:12 PM, Abe Dillon wrote: > The syntax of this proposal is almost objectively disgusting. It's truly > horrid. I don't know how many ways to say it. Almost. Except for the problem that "disgusting" is a subjective term. If you want to say that this is *objectively

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-29 Thread Chris Angelico
On Sun, Jul 29, 2018 at 8:32 PM, David Mertz wrote: > I can hardly imagine a stronger bug magnet than PEP 505. The hyperbole in this thread is impressive. Not just "I can hardly imagine anyone PROPOSING a stronger bug magnet". You cannot imagine one even existing. And this is after people have

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Chris Angelico
On Fri, Jul 27, 2018 at 7:45 PM, Thomas Jollans wrote: > On 27/07/18 08:06, Robert Vanden Eynde wrote: > > Thanks for your response, I want to print/repr an OrderedDict() without > relying on the fact that "dict are ordered" ie. I want a solution < python > 3.7. > Currently, if I do repr(

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 12:30 PM, David Mertz wrote: > Btw. Here's a way of spelling the proposed syntax that gets the semantics > right: > # pip install coalescing NullCoalesce(spam).eggs.bacon Let's try it. rosuav@sikorsky:~$ sudo python3 -m pip install coalescing Collecting

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 1:19 PM, David Mertz wrote: > On Wed, Jul 25, 2018 at 11:08 PM Chris Angelico wrote: >> >> > Yeah, yeah. I know it's alpha software I wrote two nights ago, and >> > slightly >> > patched 5 minutes before that post. You fixed those c

Re: [Python-ideas] Python docs page: In what ways is None special

2018-07-26 Thread Chris Angelico
On Fri, Jul 27, 2018 at 9:20 AM, Michael Selik wrote: > On Mon, Jul 23, 2018 at 2:03 AM Jonathan Fine wrote: >> >> Thank you for your attention. What have I missed? > > > None and a few other things are special-cased by CPython. The compiler won't > bother to write bytecode instructions when an

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 12:14 PM, David Mertz wrote: > So now at least TWO proponents of 505 cannot successfully translate a very > simple example taken almost directly from the PEP! > > Is that REALLY a good argument for it being helpful, and not being a bug > magnet?! > Okay. I'll give you the

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 11:45 AM, Nicholas Chammas wrote: > On Wed, Jul 25, 2018 at 9:20 PM Chris Angelico wrote: >> >> On Thu, Jul 26, 2018 at 11:02 AM, David Mertz wrote: >> > That is disingenuous, I think. Can this raise an AttributeError? >> > >> >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 12:56 PM, David Mertz wrote: > On Wed, Jul 25, 2018 at 10:41 PM Chris Angelico wrote: >> >> A bit problematic. But after (a) figuring out that your module is >> named "coalesce" even though I installed "coalescing" AND (b)

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-25 Thread Chris Angelico
On Thu, Jul 26, 2018 at 12:45 PM, David Mertz wrote: > On Wed, Jul 25, 2018 at 10:29 PM Chris Angelico wrote: >> It is *actually impossible* to >> perfectly represent short-circuiting semantics in Python! > > > It's INCREDIBLY EASY to represent short-circuiting s

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Chris Angelico
On Fri, Jul 27, 2018 at 9:24 PM, Serhiy Storchaka wrote: > 27.07.18 12:53, Chris Angelico пише: >>>>> >>>>> from collections import OrderedDict >>>>> od = OrderedDict([('a', 1), ('b', 2)]) >>>>> dict.__repr__(od) >> >&g

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 5:40 PM, Jonathan Fine wrote: > Hi Chris > > Thank you for your prompt reply. You wrote > >> Incorrect. The short-circuiting behaviour ends at any sort of >> grouping. It's like how "a < b < c" is not equivalent to "(a < b) < >> c", nor to "a < (b < c)". > > You've told me

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 6:00 PM, Jonathan Fine wrote: > Hi Chris > > You wrote: > >> Oh. The equivalent ones are #1 and #2, and #7 and #8, where this >> proposal doesn't change anything. Otherwise, they're not equivalent. > > Are you sure. I'd also expect #10 and #11 to be equivalent. > > By the

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 6:45 PM, Jonathan Fine wrote: > Hi Chris > > Thank you for your reply. I think we're making good progress. > > You wrote > >>> 10) a ?. b ?. c >>> 11) (a ?. b) ?. c >> >> I would parse those differently, but you may be right that they'll >> always have the same final

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 5:29 PM, Jonathan Fine wrote: > Hi All > > I have two further questions. I'm keen to clarify what is the > behaviour specified by PEP 505. I'm not, at this time, interested in > why and how PEP 505 specifies behaviour. I just wish, through explicit > examples, to clarify

Re: [Python-ideas] PEP 505: None-aware operators

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 7:09 PM, Jonathan Fine wrote: > Hi Chris > > We're discussing. >> 10) a ?. b ?. c >> 11) (a ?. b) ?. c > > I asked >> So, are there any values of 'a' for which #10 and #11 don't give the >> same result? > > You replied >> I'm not prepared to put my neck out and say "They

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-04 Thread Chris Angelico
On Sun, Aug 5, 2018 at 4:40 AM, Todd wrote: > > > On Sat, Aug 4, 2018 at 9:13 AM, Steven D'Aprano wrote: >> >> On Fri, Aug 03, 2018 at 03:17:42PM -0400, Todd wrote: >> >> > Boolean operators like the sort I am discussing have been a standard >> > part >> > of programming languages since forever.

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-04 Thread Chris Angelico
On Sun, Aug 5, 2018 at 2:37 AM, Steven D'Aprano wrote: > All this supposes that there is sufficient benefit to allowing custom > infix operators, including overridable or/and/xor, which is not yet > shown. Part of the justification for that is that the bitwise operators have different precedence

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-08 Thread Chris Angelico
On Wed, Aug 8, 2018 at 5:05 PM, Barry Scott wrote: > But so long as you do not leak the generator the file will be closed > immediately after the loop as the ref count of the generater hits 0. Technically that's not guaranteed (since refcounts aren't a language feature), but if you're using this

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-08 Thread Chris Angelico
On Wed, Aug 8, 2018 at 4:14 PM, Ken Hilton wrote: > This mostly springs off of a comment I saw in some thread. > > The point of a with statement is that it ensures that some resource will be > disposed of, yes? For example, this: > > with open(filename) as f: > contents = f.read() > >

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-08 Thread Chris Angelico
On Wed, Aug 8, 2018 at 10:32 PM, Oscar Benjamin wrote: > Without the context manager you could write: > > def read_multiple(*filenames): > for filename in filenames: > f = open(filename) > yield f.read() > f.close() > > Which also only leaks one

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 4:00 AM, Bruce Leban wrote: > And as to saying a lambda function is an "anonymous function": the anonymity > is not a property of the function. If I assign it to a name, it's no longer > anonymous. Really a "lambda" or "lambda function" is just a function, but > "lambda"

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 5:08 AM, Abe Dillon wrote: > The whole point of a programming language is to bridge the gap between > machine code and natural language (in Python's case English, as with most > other languages). It's to make reading and writing code easier through > abstraction, not to

Re: [Python-ideas] Toxic forum

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 3:06 AM, Michael Selik wrote: > > > On Mon, Aug 13, 2018, 5:59 AM Nicholas Chammas > wrote: >> >> Maybe we need to revive that discussion? Overall, I don’t think we have a >> people problem on this list as much as we have an administration tooling >> problem. > > > +1 > >

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 6:26 AM, Abe Dillon wrote: > [Chris Angelico] >> >> > The whole point of a programming language is to bridge the gap between >> > machine code and natural language (in Python's case English, as with >> > most >> > other lang

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 7:40 AM, Abe Dillon wrote: > Jumping into functions that mutate variables in the calling scope sounds a > lot like "GoTo" which is notorious for leading to code that's very hard to > reason about. Your functions would implicitly require that you assign > variables in the

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 4:52 AM, Jacob Solinsky wrote: > -Jumping to a function as opposed to calling a function > > When a function is jumped to, it inherits the variables in the caller’s local > namespace and is free to modify them or add new local variables, unlike a > normal function call,

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 8:53 AM, Jacob Solinsky wrote: > What I had hoped to do was use a preamble code block to collect all of the > most common queries called by the mutate function in the local namespace, > for example > > C = 'bpgkdtszSZjCmnywh' > M = 'mn' > > > class Morpheme: > #stuff >

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 7:58 AM, Greg Ewing wrote: > Chris Angelico wrote: >> >> No, lambda calculus isn't on par with brakes - but anonymous functions >> are, and if they're called "lambda", you just learn that. > > > It's like saying that people

Re: [Python-ideas] Python docs: page: In what ways in None special

2018-08-14 Thread Chris Angelico
On Wed, Aug 15, 2018 at 9:09 AM, Chris Barker via Python-ideas wrote: > no, it's not -- None is keyword, and just like any other keyword, it can't > be re-bound. However, every other keyword I tried to rebind results in a > generic: > > SyntaxError: invalid syntax > > (except None, True, and

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Chris Angelico
On Fri, Aug 17, 2018 at 5:32 AM, Chris Barker via Python-ideas wrote: > hmm -- made me think that generators are doing something different here -- > and indeed they are. If you use regular functions: > > In [30]: def local_modifying(loc): > ...: """ > ...: adds a "fred" key to the

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-12 Thread Chris Angelico
On Mon, Aug 13, 2018 at 1:31 PM, Abe Dillon wrote: > [Steven D'Aprano] >> >> Just because I challenge your statements doesn't mean I'm attacking you. > > > No. Telling me I'm having an extreme overreaction means you're attacking me. If your reaction was extreme, saying so isn't attacking you. >

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-12 Thread Chris Angelico
On Mon, Aug 13, 2018 at 2:56 PM, Abe Dillon wrote: > [Chris Angelico] >> >> Also, the signature is most decidedly NOT obvious from context > > Who decided this? It's been decided by some committee? When you write a key > function, you don't know how many argument

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Angelico
On Tue, Aug 21, 2018 at 2:16 AM, Chris Barker via Python-ideas wrote: > On Mon, Aug 20, 2018 at 7:21 AM, Steven D'Aprano > wrote: >> >> * Introducing a warning makes it clear that this is not a de facto >> language standard, but a mere implementation detail subject to >> change if somebody

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-20 Thread Chris Angelico
On Tue, Aug 21, 2018 at 12:21 AM, Steven D'Aprano wrote: > On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote: > > [...] >> > > e) It leaves a room for a future changes (In fact, in some situations I >> > > would like to have this possibility). > > [Chris] >> > Related to (e) is that

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 12:57 PM, Abe Dillon wrote: > [Chris Angelico] >> >> If you have a use-case for a lambda function that takes a callback and >> has a default value for that callback, please submit it to The Daily >> WTF. In Steve's example, the main function was

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 8:45 AM, Abe Dillon wrote: > [Chris Angelico] >> >> Python's parser is *deliberately* incapable of backtracking this far >> in its definition of syntax. > > > Can you explain how far the parser is capable of backtracking? > It seems li

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 12:48 PM, Abe Dillon wrote: > [Steven D'Aprano] >> >> Replacing the keyword: >> results = map(def a, b=2, c=3: a ** b / c, sequence) >> widget.register(callback=def: spam.eggs()) >> Doesn't look so attractive now, I wager. Using "def" inside an >> expression looks

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Chris Angelico
On Thu, Aug 23, 2018 at 10:44 AM, Abe Dillon wrote: > The problem goes beyond just learning the term lambda, it can increase > mental load on an already mentally demanding activity to have to translate > an unfamiliar word every time you see it. It's lack of relation to anything > else makes it

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Chris Angelico
On Thu, Aug 23, 2018 at 11:59 AM, Abe Dillon wrote: > [Chris Angelico] >> >> > I've also argued that the very form of lambda expressions is noisier >> > than it >> > otherwise needs to be. It's not like noise is only distracting to novice >> >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Chris Angelico
On Thu, Aug 23, 2018 at 9:02 AM, Greg Ewing wrote: > Rhodri James wrote: >> >> This, by the way, is why think using the same syntax for function >> definition and generator definition was a mistake. > > > I think I remember arguing the same thing back when generators > were being devised. > > But

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread Chris Angelico
On Sat, Aug 25, 2018 at 5:13 AM, Mike Barnett wrote: > Here we go: > > Take 3 numbers as input (A, B, C). Add them together. Display the result in > a simple pop-up window. > > That’s a pretty typical kind of problem for the first few weeks of beginning > programming. Maybe first few days. >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 3:56 AM, Abe Dillon wrote: > I've never hears someone say, "My child's name will be if it's a girl Sally > otherwise Billy." "My child's name depends on gender - if it's a girl, Sally, otherwise Billy." Seems fine to me. You can always come up with something awkward in a

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 2:55 AM, Jonathan Fine wrote: > Nick Loadholtes wrote (elsewhere, quoted in this thread - by me). > >> Make your docs work as hard as your code does. Clear examples will >> make your code stand out in a good way. > > With a bit more searching I found: > >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 4:56 AM, Abe Dillon wrote: > [Chris Angelico] >> >> In English, "card is not wild" can >> be interpreted as a membership check, but in Python, it is only an >> identity check; you're capitalizing on false readability by using this >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 6:33 AM, Abe Dillon wrote: > [Chris Angelico] >> >> I use decks of cards primarily for non-game >> usage (for instance, teaching data structures and algorithms - cards >> laid out on a table can represent a tree, heap, array, etc) > >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-21 Thread Chris Angelico
On Wed, Aug 22, 2018 at 6:24 AM, Abe Dillon wrote: > [Chris Angelico] >> >> That right there is unacceptable. You should not have to know the >> destination to understand what something fundamentally is. > > > You don't *have* to know what the parameter "key&

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-19 Thread Chris Angelico
On Mon, Aug 20, 2018 at 12:43 AM, Kirill Balunov wrote: > > чт, 16 авг. 2018 г. в 22:37, Chris Barker via Python-ideas > : >> >> >> I wonder why locals doesn't return a Mapping Proxy, or other read-only >> mapping object? >> >> If it's not guaranteed to be THE locals dict, and changes *may* not

Re: [Python-ideas] Asynchronous friendly iterables

2018-08-20 Thread Chris Angelico
On Mon, Aug 20, 2018 at 5:34 PM, Simon De Greve wrote: > Do you mean that for loops inside an "async def" statements are always > executed as 'async for' loops? That's what I wanted to acheive by writing > the AsyncDict class (c.f. the CodeReview link). The point of an 'async for' loop is that

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-27 Thread Chris Angelico
On Mon, Aug 27, 2018 at 10:50 PM, Steven D'Aprano wrote: > On Mon, Aug 27, 2018 at 12:12:22PM +0100, Ivan Levkivskyi wrote: >> Contract in 99% of cases is just another word for type (maybe a very >> complex type like `DAG[T] <: Graph[T]`). >> Everything else, like `x >= y` is better expressed as

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-08-28 Thread Chris Angelico
On Tue, Aug 28, 2018 at 6:05 PM, Stephen J. Turnbull wrote: > In the case in point, the destructuring assignments > > a, b = b, a > w, x, y, z = z, w, y, x > > can be interpreted as "swapping" or "permuting", and AIUI that's why > they were included. They express the intent better than >

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Chris Angelico
On Thu, Aug 23, 2018 at 6:24 AM, David Mertz wrote: > Oops. I blame the partial editing of copy/padte on doing it on my phone. I > meant this, of course: > > widget.register(callback=spam.eggs) This isn't quite the same, incidentally. It's (mostly) equivalent to: widget.register(callback=lambda

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Chris Angelico
On Thu, Aug 23, 2018 at 3:56 AM, Rhodri James wrote: > On 22/08/18 14:38, Jonathan Fine wrote: > def fn(): >> >> ... if None: >> ... yield >> ... > > list(fn()) # Fails, unless fn is a generator function. >> >> [] Actually, it fails unless fn returns some sort of

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Chris Angelico
On Thu, Jul 19, 2018 at 9:55 AM, Giampaolo Rodola' wrote: [ please trim quotes, you just quoted the entire PEP in your post ] > With all due respect (and I am sorry for being “vocal” about a PEP once > again) I find this simply ugly. To me this basically doesn’t look like > python anymore, so a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 5:10 PM, Grégory Lielens wrote: > > >> On 2018-07-19 02:11, Chris Angelico wrote: > > >> >> -snip- >> As far as I can see, these null-coalescing operators would break >> that >> model. The PEP doesn't seem to pro

Re: [Python-ideas] Idea: Deferred Default Arguments?

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 7:03 PM, Peter O'Connor wrote: > Often when programming I run into a situation where it would be nice to have > "deferred defaults". Here is an example of what I mean: > > def subfunction_1(a=2, b=3, c=4): > return a+b*c > > def subfunction_2(d=5, e=6,

Re: [Python-ideas] Adding Python interpreter info to "pip install"

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 5:56 PM, Thomas Jollans wrote: > On 20/07/18 05:10, Al Sweigart wrote: >> Sorry, I meant "pip list", rather than "pip info". >> >> I thought about the fact that "pip --version" provides this info, but 1) >> it provides the location of pip, not the python interpreter it

Re: [Python-ideas] Adding Python interpreter info to "pip install"

2018-07-19 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:45 AM, Al Sweigart wrote: > The goal of this idea is to make it easier to find out when someone has > installed packages for the wrong python installation. I'm coming across > quite a few StackOverflow posts and emails where beginners are using pip to > install a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:03 AM, Greg Ewing wrote: > Rhodri James wrote: >> >> If anyone can think of a good word for "if it isn't None, otherwise", I'd >> be all for it :-) > > > I don't think there's any single Engish word that captures > all of that, so we'd have to invent one. > > Some

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:14 PM, Rhodri James wrote: > I go with SF fandom's traditional :-) definition: "somebody did it once." > If it's been done more than once, it's an honoured tradition. But if Shakespeare did it, it's just the way the language is. I think Fortran is the programming

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:24 PM, Paul Moore wrote: > On 20 July 2018 at 13:16, Chris Angelico wrote: >> On Fri, Jul 20, 2018 at 10:14 PM, Rhodri James wrote: >>> I go with SF fandom's traditional :-) definition: "somebody did it once." >>> If it's been

Re: [Python-ideas] Multi-core reference count garbage collection

2018-07-20 Thread Chris Angelico
On Sat, Jul 21, 2018 at 6:44 AM, Jonathan Fine wrote: > Hi Steve > > You wrote: >> My understanding is that reference counting is both deterministic and >> immediate. Shifting the reference counting into another thread so that >> it becomes non-deterministic and potentially delayed doesn't sound

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-15 Thread Chris Angelico
On Mon, Jul 16, 2018 at 1:21 PM, Nathaniel Smith wrote: > On Sun, Jul 15, 2018 at 6:00 PM, Chris Angelico wrote: >> On Mon, Jul 16, 2018 at 10:31 AM, Nathaniel Smith wrote: >>> On Sun, Jul 8, 2018 at 11:27 AM, David Foster wrote: >>>> * The Actor model ca

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-15 Thread Chris Angelico
On Mon, Jul 16, 2018 at 10:31 AM, Nathaniel Smith wrote: > On Sun, Jul 8, 2018 at 11:27 AM, David Foster wrote: >> * The Actor model can be used with some effort via the “multiprocessing” >> module, but it doesn’t seem that streamlined and forces there to be a >> separate OS process per line of

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-15 Thread Chris Angelico
On Mon, Jul 16, 2018 at 3:00 PM, Stephan Houben wrote: > What about the following model: you have N Python interpreters, each with > their own GIL. Each *Python* object belongs to precisely one interpreter. > > However, the interpreters share some common data storage: perhaps a shared > Numpy

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-23 Thread Chris Angelico
On Tue, Jul 24, 2018 at 8:22 AM, Thomas Jollans wrote: > On 18/07/18 19:43, Steve Dower wrote: >> When a ``None``-aware operator is present, the left-to-right evaluation >> may be >> short-circuited. For example, ``await a?.b(c).d?[e]`` is evaluated:: >> >> _v = a >> if _v is not None: >>

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-23 Thread Chris Angelico
On Tue, Jul 24, 2018 at 8:05 AM, Giampaolo Rodola' wrote: > The argument about this is that '?.' short-circuits execution > *silently*. Instead of AttributeError you get None. You may chain ?. > in order to lazily traverse a long tree, inadvertently assign None to > a variable, continue code

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-24 Thread Chris Angelico
On Tue, Jul 24, 2018 at 5:26 PM, Brice Parent wrote: > Le 24/07/2018 à 00:39, Chris Angelico a écrit : >> >> On Tue, Jul 24, 2018 at 8:22 AM, Thomas Jollans wrote: > > ... >> >> What about: >> >> 5 < x < 10 >> >> Can you add parent

  1   2   3   4   5   6   7   8   9   >