Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-28 Thread Jonathan Fine
Hi All I've followed my own advice, earlier in this thread. The newly created repository https://github.com/jfine2358/py-jfine2358 contains personal Python code that others might find useful. And you'll find in it: === https://github.com/jfine2358/py-jfine2358/blob/master/jfine2358/itertools.py

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

2018-08-01 Thread Jonathan Fine
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 value that is not None === I gave (42).str as an example. I wrote >

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread Jonathan Fine
Hi Eric [Steve Dower: Eric seems to have found a bug in the PEP. Where to report?] You quoted, from PEP 505, Before > mangle_from_ = True if policy is None else policy.mangle_from_ After > mangle_from_ = policy?.mangle_from_ ?? True You then remarked > I cannot see how these are equivalent I

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-03 Thread Jonathan Fine
Hi Alexandre Thank you for your post. In PEP 505 the context for the example being discussed is: > Some of these are shown below as examples before and after converting to use > the new operators. You wrote: > So yes, *strictly speaking* the two chunks of code are not exactly the same. I see

Re: [Python-ideas] Redefining method

2018-07-30 Thread Jonathan Fine
Hi Jamesie Thank you for your question. You asked why not > c = MyClass > o = c() > > def c.foo(cls): ... > def o.bar(self): ... I've the same same query, but never had the courage to ask. So that you for asking. And also giving me a chance to share my thoughts. In Ruby, I believe, you can

Re: [Python-ideas] slice[] to get more complex slices

2018-07-28 Thread Jonathan Fine
Hi Stephan I took a look at your personal web site. Your PhD sounds interesting. Quantum coherence and photosynthesis. But off-topic here. (Sadly, personal web sites are a bit of mess.) You wrote: > I'd really like to move this proposal forward in some form. +10 > As a next step, would it be

Re: [Python-ideas] As-do statements/anonymous blocks in python

2018-07-28 Thread Jonathan Fine
Hi James This is an attempt to respond to the issues that be lying behind your request for code blocks in Python. It's my two cents worth (https://en.wikipedia.org/wiki/My_two_cents) of opinion. I really do wish we could have language that had all of Ruby's strengths, and also all of Python's.

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

2018-07-26 Thread Jonathan Fine
Hi All To start this thread, on 18 July, Steve Dower wrote: > Possibly this is exactly the wrong time to propose the next big syntax > change, since we currently have nobody to declare on it, but since we're > likely to argue for a while anyway it probably can't hurt (and maybe this > will become

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

2018-07-31 Thread Jonathan Fine
David Mertz wrote: > `spam?.eggs?.cheese?.aardvark` is NOT redundant for > `spam?.eggs.cheese.aardvark`. The two expressions simply do different > things [...] I agree, assuming ?. is a binary operator. Given this, in Python (+ PEP 505) one can write tmp = spam ?. eggs val1 = tmp ?.

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

2018-07-31 Thread Jonathan Fine
Stephan Houben wrote: > Nope, the introduction of the tmp variable changed the semantics. It isn't a > "chain" anymore so it breaks shortcutting. I'm confused. Assume 'a' is not defined. With Python's dot (attribute access) we have >>> a.b.c NameError: name 'a' is not defined >>> a.(b.c)

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

2018-08-01 Thread Jonathan Fine
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 the behaviour that is specified. Here 'a' is an identifier.

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

2018-08-01 Thread Jonathan Fine
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 way, there's a typo in my examples: 11) (a .? b) ?. c -- Jonathan

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

2018-08-01 Thread Jonathan Fine
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 are absolutely > identical" and have people jump on me with some

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

2018-08-01 Thread Jonathan Fine
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 that my answer B is wrong. But you've not provided your correct

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

2018-08-01 Thread Jonathan Fine
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 result. I'd like to get some certainty on this. I'm not aware of any

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

2018-08-01 Thread Jonathan Fine
Hi Stephan You wrote > Let me stand up and claim that if a chain consists *only* of None-coalescing > operations, then breaking up the chain by adding parentheses does not > matter, ever. You missed a post I made, 17 minutes before yours. I then believed that PEP 505 specified. #1. (None ?.

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

2018-08-04 Thread Jonathan Fine
Here's my opinion, in a nutshell. A diet with a small amount of sugar is healthy. But too much sugar is not. https://www.nhs.uk/live-well/eat-well/how-does-sugar-in-our-diet-affect-our-health/ I have a similar attitude to syntactic sugar. Sometimes helpful.

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

2018-08-03 Thread Jonathan Fine
Hi Todd Thank you for your contribution! I've got a couple of comments. The experts, I hope, will have more to say. You wrote: > As to why this is useful, the overall problem is that the current logical > operators, like and, or, and not, cannot be overloaded, which means projects > like numpy

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Jonathan Fine
Hi Peter Thank you for your deferred default values idea, which we're now working on together. https://github.com/petered/peters_example_code/blob/master/peters_example_code/deferral.py You wrote: > I find that about 90% of the time I want want to zip iterators together, I > expect them to be

[Python-ideas] Python Community Code of Conduct

2018-08-13 Thread Jonathan Fine
https://www.python.org/psf/codeofconduct/ Python Community Code of Conduct The Python community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences great successes and continued

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

2018-08-15 Thread Jonathan Fine
Steve Barnes and Greg Ewing wrote: >> * A dinosaur is specifically an extinct terrible (formerly considered) >> lizard > > > Which technically is not a lizard. I can't resist. Puffinus puffinus is the scientific name for (drum roll) no, not the Atlantic (or common) Puffin but (off-pitch

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

2018-08-15 Thread Jonathan Fine
Hi Jacob Thank you for your problem. I'll focus on your simple example (lightly edited for clarity) > Let foo(a, b) be the syntax to call foo(a, b), and foo(a, b)% be the syntax > to jump to foo(a, b) > > c = 5 > > def foo(a): > return a + c > > def bar(a, c): > return foo(a) >

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

2018-08-15 Thread Jonathan Fine
Hi Thank you all, for the kind words and appreciation, and the comments and suggestions. I have time now to respond to one comment. Please note that is just my opinion, and your opinion may be different. Rhodri James prefers

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

2018-08-16 Thread Jonathan Fine
Hi Marko Thank you for introducing yourself, and clearly stating your question. That helps us all. You asked: > Could somebody update me on the state of the discussion on this matter? I think bring the existing PEP up to date would be a good starting point. Its content hasn't been changed since

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

2018-08-14 Thread Jonathan Fine
Hi I'm pleased to announce that I've completed the first draft of my page. It's viewable on gitub. https://github.com/jfine2358/py-jfine2358/blob/master/docs/none-is-special.md To quote from that page: This page arose from a thread on the python-ideas list. I thank Steve Dower, Paul Moore,

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

2018-08-16 Thread Jonathan Fine
Hi Neil Thank you for your post, regarding https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy. You've suggested changing "built-in name None" to "keyword None". I think that's a good change. And similar changes might be welcome elsewhere in the docs, perhaps also for

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

2018-08-16 Thread Jonathan Fine
Hi Rhodri Thank you for your message. You wrote: > I disagree. That original text looks like it has been very carefully > written to be (almost) true. What you are proposing to replace it with is > less true and confusing to boot. The decision is neither your's nor mine. It is for the Python

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

2018-08-16 Thread Jonathan Fine
Hi Paul Thank you for your comments. I think different people experience things in different ways, based on who they are. What their background, training, experience are. One person's precision is another's pedantry. An aside. Babbage and Tennyson: https://www.uh.edu/engines/epi879.htm You

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

2018-08-16 Thread Jonathan Fine
Hi Chris Steve and you wrote: >> there >> are times where I have really wanted to access the caller's environment, >> not the environment where my function was defined. > what am I missing? can't you get that by passing locals() in to a function? I think this will fail when values are changed.

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

2018-08-16 Thread Jonathan Fine
Hi Paul We wrote >> I'd like to take this to bugs.python.org, if only to provide another >> route to discovering this (very useful) conversation. > > That's perfectly OK, and entirely your choice. However, if you do so, > I'd hope that you present the dissenting views from this list when you >

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

2018-08-16 Thread Jonathan Fine
Hi Jacob I really like your previous post. I find it really helps me understand what you want. You wrote > I wanted the called, jumped to function to change state in the caller. > From what I tried to do, passing locals() cannot accomplish this. I have > made it happen in other languages though.

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

2018-08-17 Thread Jonathan Fine
Jacob Solinsky wrote: > So when getx is executed inside a let form, if it tries to read/write the > value of X it interacts with the X entry in the let form's symbol table > before moving to find X in the global environment, right? The context for this is two (very useful) URLs I sent him off

Re: [Python-ideas] Python certification

2018-08-09 Thread Jonathan Fine
Hi Oleg You wrote >In what way certification programs are related to documentation, > especially to the tutorial? One way is through syllabus. Necessarily, a certification via exam requires a syllabus (or a course of study). There is, implicitly, a syllabus in

Re: [Python-ideas] Python certification

2018-08-09 Thread Jonathan Fine
Hi Patrick and Oleg Thank you, respectively, for a good question and a helpful response. Patrick asks: > Does anyone know of any PSF approved training or certifications for Python > developers? Oleg writes: > The python-ideas list is for discussing more speculative design ideas of > Python

Re: [Python-ideas] File format for automatic and manual tests

2018-08-08 Thread Jonathan Fine
Hi Victor Thank you for your contribution, regarding standards for Python tools. Here is my two cents worth. You wrote: > We need a standard to make PyCharm and others to conform to it. Things don't quite work that way, in the Python community. True, we have a Benevolent Dictator For Life

Re: [Python-ideas] Conduct on python-ideas

2018-08-14 Thread Jonathan Fine
Hi Everyone Brett Cannon wrote: > I shouldn't be having to explain to adults on how to communicate among > strangers of different cultures, but here we are. I did an entire PyCon US > keynote on why we need to treat open source as a series of kindnesses and > react as such:

[Python-ideas] Documentation of locals()

2018-08-20 Thread Jonathan Fine
Summary: There's prior art in bug.python.org relating to off-thread topic discussion of locals(). Suggest work on closing open documentation issues relating to locals(). In the thread === Jump to function as an an alternative to call function

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

2018-08-20 Thread Jonathan Fine
Hi I've created new thread === Documentation of locals() https://mail.python.org/pipermail/python-ideas/2018-August/052843.html Summary: There's prior art in bug.python.org relating to off-thread topic discussion of locals(). Suggest work on closing open documentation issues relating to

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

2018-08-21 Thread Jonathan Fine
Hi Earlier today, I did a search for 'documentation by example python' and found Example of great documentation in Python: Nick Loadholtes (copied) https://ironboundsoftware.com/blog/2017/12/11/great-documentation-python/ The example is:

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

2018-08-21 Thread Jonathan Fine
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] A simple proposal concerning lambda

2018-08-21 Thread Jonathan Fine
Hi Abe Summary: You've done good work here. I've skim read the 2006 discussion you found. You wrote: > I'm trying to dig up past threads about alternatives to lambda because I > would be astonished if "def" hadn't been considered and rejected for some > reason. What I've found so far is this

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

2018-08-23 Thread Jonathan Fine
Hi Mike Thank you for your message. I agree, in broad terms, with your statement of goals, and welcome their being discussed here. Python has important roots are in education. We benefit from taking care of them. Here is what I take to be your statement of goals. > While the Python language is

[Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread Jonathan Fine
Here's what I call a simple proposal. Some people might find it outrageous. Today is not 1st April. BACKGROUND Many Python users don't like the name lambda. But many Python users don't want any change here. This is true because there are millions of Python users, and even 100 is

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

2018-08-21 Thread Jonathan Fine
Hi Steve You wrote: > I would just like to point out that the ipython %paste magic very > handily strips leading >, ... & + characters from the pasted block, > (there is also some clever dedenting done). [useful example, snipped] > Which is ideal. I personally find that many beginners get on a

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

2018-08-21 Thread Jonathan Fine
Hi Greg You (and a reddit user) wrote: >> Matlab says: "Here, copy paste this and it'll work". >> To the point that the workspace is designed to automatically strip >>> >> from any copy and pasted commands. > Maybe this is something Python's REPL should do? Good idea. Maybe this is something

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

2018-08-21 Thread Jonathan Fine
Chris Angelico wrote > Where in the linked-to What's New page is there an example of that? > There are several code blocks that ARE copy/pasteable, even into the > vanilla interpreter. Good question. The reddit user wrote.

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

2018-08-21 Thread Jonathan Fine
I wrote: > No mention here, or elsewhere on the page, that [>>>] at the top > right of a code example toggles the presence or absence of prompts. Now raised, and cross-referenced as an issue. https://bugs.python.org/issue34451 docs: tutorial/introduction doesn't mention toggle of prompts

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

2018-08-21 Thread Jonathan Fine
Hi Abe First, I have reservations about the name lambda. But there's a lot of code out there that uses lambda, and I'd like that code to continue to run. You wrote: > func = value[card.suit] if card not in wilds else wild_value with card I thought I'd try this, and variants, in the Python

Re: [Python-ideas] Unpacking iterables for augmented assignment

2018-08-25 Thread Jonathan Fine
Hi James Thank you for the simple example. It makes discussing your proposal much easier. I hope you don't mind, I'll modify it a little to make the semantics clearer, at least to me. Here it is. init = (10, 20) incr = (1, 2) (a, b) = init # Now, (a, b) == (10, 20) a, b += incr # Now (a, b)

Re: [Python-ideas] Unpacking iterables for augmented assignment

2018-08-26 Thread Jonathan Fine
Hi James and Steve Myself and Steve wrote: >> Notice that '+=' creates uses the same object when the object is a >> list, but creates a new object. This raises the question: Why and how >> does Python behave in this way? > Lists are mutable and can be modified in place. Tuples are immutable and

Re: [Python-ideas] Unpacking iterables for augmented assignment

2018-08-26 Thread Jonathan Fine
Hi James Thank you for your message. I have some general, background comments. However, the question remains: Does your proposal sit well with the rest of Python? By the way, I've just found a nice article: http://treyhunner.com/2018/03/tuple-unpacking-improves-python-code-readability/ You

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

2018-08-28 Thread Jonathan Fine
Guido wrote > Perhaps someone can do some research and unearth real code that contains > series of += assignments that would become more readable by collapsing them > into a single line using the proposed construct. Here's some notes towards finding (or constructing) such examples. First note

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

2018-08-19 Thread Jonathan Fine
Hi Stephen Thank you for your message. I'll respond just to a few of your comments. HOW MUCH EFFORT ON DOCS == Myself and you wrote: >> Summary: Discussion of the words 'jargon' and 'chatter'. Recommend >> that we learn better how to find a compromise (strike a

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

2018-08-19 Thread Jonathan Fine
Hi Stephen I've just been reading the (excellent) discussion, started by Victor Stinner [Python-Dev] Translated Python documentation https://mail.python.org/pipermail/python-dev/2017-February/147416.html # Start of thread. You wrote, and asked for comments on: > Finally, before getting the

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

2018-08-18 Thread Jonathan Fine
Summary: Discussion of the words 'jargon' and 'chatter'. Recommend that we > learn better how to find a compromise (strike a balance) between precision and simplicity. This thread is, in part, about the meaning, use and usefulness of words. And 'jargon' is what we are talking about. What is the

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

2018-08-18 Thread Jonathan Fine
Summary: I look at the phrase 'strike a balance' in different languages, and rewrite some wikipedia text on accessibility. I found in https://en.wikipedia.org/wiki/Jargon#Accessibility_issues === There is a balance to be struck, as excessive removal of technical terminology from a document leads

Re: [Python-ideas] Unpacking iterables for augmented assignment

2018-08-27 Thread Jonathan Fine
James has suggested that Python be enhanced so that >>> a, b += c, d is a short-hand for >>> a += c >>> b += d Myself, James and Matthew wrote >> > Does it IN PRACTICE bring sufficient benefits to users? >> I found myself needing this when I was writing a monte-carlo >> simulation in python

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

2018-08-27 Thread Jonathan Fine
Ivan and Steve wrote >> TBH, I think one of the main points of design by contract is that contracts >> are verified statically. > No, that's not correct. > https://www.eiffel.org/doc/eiffel/ET-_Design_by_Contract_%28tm%29%2C_Assertions_and_Exceptions The page from Steve supplied (URL above)

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

2018-08-22 Thread Jonathan Fine
Hi Rhodri You wrote: >This, by the way, is why think using the same syntax for function definition >and generator definition was a mistake. It's only when I reach a "yield" >statement that I realise my expectations for this code are wrong. Here's something that might help, and surprise, you.

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

2018-08-22 Thread Jonathan Fine
I wrote: > Here is my simple proposal. Enhance Python to allow > > >>> hn = def a, b=2, c=3: a ** b / c I'd like to add a clarification. Here are two proposals. ONE. Wherever you could have used 'lambda', you now have a choice. You can still use 'lambda', or you can use 'def' instead. The

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

2018-08-22 Thread Jonathan Fine
Hi Steve You and I have different experience, background and interests. You wrote > As educators, if we fail to teach the technical language of a field to > our students, we are failing to prepare those students to enter that > field. Technical jargon is the language of the field. Python is a

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

2018-08-29 Thread Jonathan Fine
This is about a difference of opinion regarding design by contract and static checking, that Steve D'Aprano has re-raised. Steve wrote that Ivan Levkivskyi's opinion was that: > contracts [are] always statically checked This is what Ivan wrote: > TBH, I think one of the main points of design by

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

2018-07-20 Thread Jonathan Fine
Hi Peter Interesting problem. We can already get something like your proposed solution by using None instead of deferred. You have to start with def subfunction_1(a=None, b=None, c=None): if a is None: a = 2 # similarly for b and c. return a+b*c You will loose the

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

2018-07-20 Thread Jonathan Fine
In an earlier post, I defined BUFFERED multi-core reference count garbage collection. The basic idea is that each worker process store in buffers the need to do an INCR and DECR on the reference count for a piece of memory with a given ID. There is then a garbage collection process that does the

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

2018-07-20 Thread Jonathan Fine
Excellent contributions. I'm going to try to (partially) consolidate what we've got. REVIEW === I'll start by reviewing the situation regarding default arguments. There are two basic patterns for default arguments. The first is --- def fn(a=EXP): # body of function --- The second is ---

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

2018-07-20 Thread Jonathan Fine
Hi Peter You make the very good point, that > subfunction_1 may be written by someone totally different from the author of > main_function, and may even be in a different codebase. For the author of > subfunction_1, it makes no sense to use the "None" approach instead of > python's normal

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

2018-07-20 Thread Jonathan Fine
Hi Peter You wrote: On Fri, Jul 20, 2018 at 3:43 PM, Peter O'Connor wrote: > Ah, right, the fix_it(fcn) is a nice idea. It might also be a good idea, if > we're making an external library anyway, to have a "deferred" object to > avoid overloading "None" (which may mean something else than

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

2018-07-20 Thread Jonathan Fine
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 like > an advantage to my naive understanding. The choice is

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

2018-07-20 Thread Jonathan Fine
Hi Steve You wrote > Sorry Jonathan, can you please explain: > > - what problem you are solving with this? > > - and what's wrong with the existing garbage collector? The problem I'm trying to solve doing multi-core reference counting garbage collection without a GIL. As far as I know, we're not

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

2018-07-21 Thread Jonathan Fine
Hi Barry We've met before. Nice to meet you again, this time electronically. You suggested that is a different problem that needs a solution. To help maintain focus, I won't respond to that now. You wrote: > I'd argue that the ref counts are not interesting at all, only a > side effect of one

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

2018-07-21 Thread Jonathan Fine
Hi Steve Thank you for your message. I think my response below allows us to go move forward. WHAT'S THE PROBLEM You asked: > What problem are you trying to solve? > Its okay if there is no immediate problem, that you're just exploring > alternative garbage collection strategies. Or if you're

Re: [Python-ideas] slice[] to get more complex slices

2018-07-23 Thread Jonathan Fine
Humour warning. Serhiy wrote: > Do you bless using __class_getitem__ for something other than typing? As in https://perldoc.perl.org/functions/bless.html, perhaps? -- Jonathan ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-23 Thread Jonathan Fine
Hi David and Paul Thank you both for your contributions, and for starting a new thread. David, you wrote > The need addressed by PEP 505 is real; I completely agree. My view is that with PEP 505 as it it, the problem is better than the solution. But all the same, something can be done to

Re: [Python-ideas] slice[] to get more complex slices

2018-07-23 Thread Jonathan Fine
Hi Grégory You wrote: > Seems that the initial proposal was skipped just for timing reasons The discussion is in https://bugs.python.org/issue24379. It was first skipped for that reason. Second time around our Then and now Former BDFL wrote === https://bugs.python.org/msg280721 Actually I'm with

Re: [Python-ideas] slice[] to get more complex slices

2018-07-23 Thread Jonathan Fine
Hi Grégory You wrote: > Oh yes , I see. Seems like almost everybody think using the [...] syntax to > define reusable slices is a good idea, > Not sure slice[1::3] can be done, but this has my preference too: it's the > most direct exposure I can think of... The slice class already has all the

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

2018-07-23 Thread Jonathan Fine
This arises out of PEP 505 - None-aware operators. I thought, a page on how None is special would be nice. I've not found such a page on the web. We do have === https://docs.python.org/3/library/constants.html None The sole value of the type NoneType. None is frequently used to represent the

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

2018-07-23 Thread Jonathan Fine
Hi Paul Thank you for your contribution > The examples are interesting, agreed. One thing they highlight to me > is that most uses of None are effectively convention. The only two > behaviours that are unique to None and implemented in the interpreter > are: > > 1. Functions that don't return an

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

2018-07-23 Thread Jonathan Fine
Hi Steve In this thread you wrote, replying to Paul Moore's comments on PEP 505 > None is already a special value. It is so special, it is one of only > three built-in values given keyword status. All the other built-ins, > including such things that are used implicitly by the interpreter (such

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

2018-07-23 Thread Jonathan Fine
Hi Steve You wrote > I think your document would be a great blog post. I don't think it is > very helpful as part of the standard documention, as it is more a > collection of arbitrary facts about None than a coherent "big picture" > document. Thank you. That's nice. However, I think there is,

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

2018-07-21 Thread Jonathan Fine
Hi Chris Thank you for your message about two processes together sorting a deck of cards. My example was in response to a comment from Steve D'Aprano. He understood in the way it was intended, which was the algorithm is in execution non-deterministic, but that the outcome is deterministic.

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

2018-07-19 Thread Jonathan Fine
an, > > 2018-07-19 8:33 GMT+02:00 Jonathan Fine : > >> I call any such scheme BUFFERED multi-core reference count garbage >> collection. The worker processes know nothing about how garbage collection >> is managed. Instead, they pass over to the GC process sufficient >> info

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Jonathan Fine
Hi > There is a formatted version of this PEP at > https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a very grateful +10 for writing a script to find such examples.) I've started a

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

2018-07-19 Thread Jonathan Fine
Hi Based on other people's work (including in particular talks by Larry Hastings) and my own thinking, I've come up with a scheme for multi-core reference count garbage collection. I think it works, and much or all of it comes from others. It might even be in the literature. Of course, if it's

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

2018-07-18 Thread Jonathan Fine
Hi Python in the age of the multi-core processor is an important question. And garbage collection is one of the many issues involved. I've been thinking about the garbage collection problem, and lurking on this list, for a while. I think it's now about time I showed myself, and shared my

Re: [Python-ideas] Make import an expression

2018-07-14 Thread Jonathan Fine
Hi Ken Thank you for your clear subject line. As you probably already know, in Python, assignments are not expressions, and so we can't write if (a=get()): # do something with a One reason for this is, perhaps, that "Explicit is better than implicit" (as in The Zen of Python, via

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

2018-07-25 Thread Jonathan Fine
Hi All INTRODUCTION This is the third and concluding post, where I describe a scheme for multi-core reference counting garbage collection. The first two posts are https://mail.python.org/pipermail/python-ideas/2018-July/052054.html

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

2018-07-24 Thread Jonathan Fine
Here's another way that None is special. === >>> NoneType = type(None) >>> >>> class myNoneType(NoneType): pass ... Traceback (most recent call last): File "", line 1, in TypeError: type 'NoneType' is not an acceptable base type === For more information see

Re: [Python-ideas] Add recordlcass to collections module

2018-09-01 Thread Jonathan Fine
Hi Martin Summary: Thank you. Your suggestion has good points. I suggest to advance it (i) provide a pure Python implementation of namedlist, and (ii) ask that the Python docs for namedtuple provide a link to namedlist. Thank you, Martin, for bringing

Re: [Python-ideas] Fix some special cases in Fractions?

2018-09-01 Thread Jonathan Fine
Greg Ewing and Jonathan Goble wrote >> Also, Fraction(1) for the second case would be flat-out wrong. > How? Raising something to the 2/3 power means squaring it and then taking > the cube root of it. -1 squared is 1, and the cube root of 1 is 1. Or am I > having a 2:30am brain fart? Let's see.

Re: [Python-ideas] Keyword only argument on function call

2018-09-06 Thread Jonathan Fine
Hi Anders Thank you for your interesting message. I'm sure it's based on a real need. You wrote: > I have a working implementation for a new syntax which would make using > keyword arguments a lot nicer. Wouldn't it be awesome if instead of: > foo(a=a, b=b, c=c, d=3, e=e) > we could

Re: [Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

2018-09-08 Thread Jonathan Fine
The problem is to improve https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1477-L1493 Here's a suggestion. For each of four permissions, the code has an assignment such as has_add_permission = inline._has_add_permission(request, obj) and the function call

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

2018-09-08 Thread Jonathan Fine
Michel Desmoulin wrote: > Isn't the purpose of "assert" to be able to do design by contract ? > > assert test, "error message is the test fail" > > I mean, you just write your test, dev get a feedback on problems, and > prod can remove all assert using -o. > > What more do you need ? Good

Re: [Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

2018-09-08 Thread Jonathan Fine
OK. Here's another piece of code to look at, from a URL that Kyle Lahnakoski posted to a different thread. https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1477-L1493 def get_inline_formsets(self, request, formsets, inline_instances, obj=None):

Re: [Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

2018-09-08 Thread Jonathan Fine
Hi Anders You wrote: > A dict merge is fairly trivial to implement to get even 2.7 support so no > need to be that restrictive. > This is a good fix for this case. I very much appreciate your openness to solutions other than the one you proposed. I like experts who are willing to change their

Re: [Python-ideas] Fwd: Add Unicode-aware str.reverse() function?

2018-09-08 Thread Jonathan Fine
Chris Angelico wrote: > Generally, problems with RTL text are *display* problems, and are not > solved by reversing strings. I very much agree with this statement, with one exception. If you wish to display RTL text on a LTR display, then a suitable reversing of strings is probably part of the

Re: [Python-ideas] Keyword only argument on function call

2018-09-06 Thread Jonathan Fine
I missed an important line of code. Here it is: >>> aaa = 'telltale' Once you have that, these will work: >>> eval('aaa', fn.__globals__) 'telltale' >>> __name__ '__main__' >>> import sys >>> getattr(sys.modules[__name__], 'aaa') 'telltale' --

Re: [Python-ideas] Keyword only argument on function call

2018-09-06 Thread Jonathan Fine
Summary: I addressed the DEFINING problem. My mistake. Some rough ideas for the CALLING problem. Anders has kindly pointed out to me, off-list, that I solved the wrong problem. His problem is CALLING the function fn, not DEFINING fn. Thank you very much for this, Anders. For calling, we can use

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

2018-09-06 Thread Jonathan Fine
Hi Franklin Lee Thank you for your message. You wrote: > We can translate the original example: > a, b, c += x, y, z > to: > a, b, c = target_list(a,b,c).__iadd__((x,y,z)) > where `target_list` is a virtual (not as in "virtual function") type > for target list constructs. Yes, we can.I

Re: [Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?

2018-08-31 Thread Jonathan Fine
James Lu started this thread by quoting me. Thank you, James, for the compliment. And I feel somewhat obliged to contribute here, are at removed I started the thread. In the message James quoted, I also said But most strengths, in another situation, can be a weakness. Language design is often a

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Jonathan Fine
Jeroen Demeyer wrote from sympy import Rational Rational(1,2) ** Rational(2,3) > 2**(1/3)/2 Rational(1,1) ** Rational(2,3) > 1 Rational(-1,1) ** Rational(2,3) > (-1)**(2/3) Rational(0,1) ** Rational(2,3) > 0 Thank you very much for this, Jeroen. Most helpful. Perhaps

  1   2   3   4   5   >