[Python-ideas] Re: Improve handling of Unicode quotes and hyphens

2020-05-10 Thread Andrew Barnert via Python-ideas
it in the field than if we try to design it here. > BTW -- there are a whole lot of Syntax Errors that a semi smart algorithm > could provide meaningful suggestions about about. I'm pretty sure that's come > up before on this list, but maybe "helpful" mode you

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-10 Thread Andrew Barnert via Python-ideas
> I do see this, though not entirely sure what to make of it: > > https://docs.python.org/3/c-api/sequence.html?highlight=sequence Yeah, the fact that sequences and mappings have identical methods means that from Python those two protocols are opt-in rather than automatic, while from C you

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-11 Thread Andrew Barnert via Python-ideas
not itself escaped? More generally, what’s the use case for %-encoding filenames like this? Are people expecting it to interact transparently with URLs, so if I save a file “spam\0eggs” in a Python script and then try to browse to file:///spam\0eggs” in a browser, the browser will convert the \0 c

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-11 Thread Andrew Barnert via Python-ideas
nothing can duck type as a string“ issue. Here’s an example that I can write in, say, Swift or Rust or even C++, but not in Python: I mmap a giant mailbox file, and I can treat that as a string without copying it anywhere. I split it into a string for each message—I don’t want to copy them all into

[Python-ideas] Re: [Suspected Spam]Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-11 Thread Andrew Barnert via Python-ideas
On May 10, 2020, at 22:36, Stephen J. Turnbull wrote: > > Andrew Barnert via Python-ideas writes: > >> A lot of people get this confused. I think the problem is that we >> don’t have a word for “iterable that’s not an iterator”, > > I think part of the proble

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-11 Thread Andrew Barnert via Python-ideas
dged sequence view. I’ve started designing such a thing multiple times, every couple years or so, and always realize it’s even more work than I thought and harder to fit into Python than i thought and give up. But maybe doing it _just_ for view slicing, rather than for everything, and requiring

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-11 Thread Andrew Barnert via Python-ideas
On May 11, 2020, at 12:59, Barry Scott wrote: > > >> On 11 May 2020, at 18:09, Andrew Barnert via Python-ideas >> wrote: >> >> More generally, what’s the use case for %-encoding filenames like this? Are >> people expecting it to interact transpar

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-11 Thread Andrew Barnert via Python-ideas
On May 11, 2020, at 12:54, Wes Turner wrote: > >  > What does sanitizepart do with newlines \n \r \r\n in filenames? Are these > control characters? >>> unicodedata.category('\n') Cc _______ Python-ideas mailing

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-11 Thread Andrew Barnert via Python-ideas
d? Most importantly, you need to clarify what the use case is, and why this proposal meets it. Otherwise, it sounds more like a trap to make people think their code is safe when it isn’t, not a fix for the real problem. ___ Python-ideas mailing list --

[Python-ideas] Re: Sanitize filename (path part)

2020-05-11 Thread Andrew Barnert via Python-ideas
know. I’m pretty sure the modern versions of Shift-JIS, EUC-*, Big5, and GB can never have continuation bytes below 0x30, but even if I’m right, are these (and UTF-8, of course) the only multi-byte encodings anyone ever uses on Unix filesystems? _______ Pyt

[Python-ideas] Re: Sanitize filename (path part)

2020-05-12 Thread Andrew Barnert via Python-ideas
ecs, they probably wouldn’t have been banned (see UTF-16LE, which is even easier to exploit this way, but unfortunately way too common). I don’t think Python comes with codecs for any of these encodings. And I don’t know of anyone who ever used them for filenames. (SCSU was the default fs enco

[Python-ideas] Re: [Suspected Spam]Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-13 Thread Andrew Barnert via Python-ideas
On May 12, 2020, at 23:29, Stephen J. Turnbull wrote: > > Andrew Barnert writes: >>> On May 10, 2020, at 22:36, Stephen J. Turnbull >>> wrote: >>> >>> Andrew Barnert via Python-ideas writes: >>> >>>> A lot of people get this

[Python-ideas] Re: Improve handling of Unicode quotes and hyphens

2020-05-13 Thread Andrew Barnert via Python-ideas
to 3.7, but has been that way back into the mists of whenever you could first write old-style import hooks, even up to the way error recovery works. I’ve taken advantage of this behavior in experimenting with new syntax. If your new syntax is not just unambiguous at the parser level, but even at the

[Python-ideas] Re: [Suspected Spam]Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-13 Thread Andrew Barnert via Python-ideas
bject > > a list_view object is a immutable sequence. indexing it returns elements from > the original list. Can we just say that it returns an immutable sequence that blah blah, without defining or naming the type of that sequence? Python doesn’t define the types of most things you never c

[Python-ideas] Re: [Suspected Spam]Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-13 Thread Andrew Barnert via Python-ideas
all know that list_view isn’t meant to name a specific type (and to be guaranteed distinct from tuple_view), I think we’ll all be fine. >> Python doesn’t define the types of most things you never construct directly. > > No, but there are ABCs so that might e the way to talk about this.

[Python-ideas] Re: [Suspected Spam]Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-13 Thread Andrew Barnert via Python-ideas
seem to be the example that many people run into first. (Or maybe lots of people do run into map first, but fewer of them get confused and need to go ask for help?) When you’re teaching a class, you can guide people to hit the things you want them to think about, but the intern, or C# guru who

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-14 Thread Andrew Barnert via Python-ideas
On May 14, 2020, at 03:01, Steven D'Aprano wrote: > > On Mon, May 11, 2020 at 10:41:06AM -0700, Andrew Barnert via Python-ideas > wrote: > >> I think in general people will expect that a slice view on a sequence >> acts like “some kind of sequence”, not like the

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-14 Thread Andrew Barnert via Python-ideas
On May 14, 2020, at 03:35, Steven D'Aprano wrote: > > On Sun, May 10, 2020 at 09:36:14PM -0700, Andrew Barnert via Python-ideas > wrote: > > >>> for i in itertools.seq_view(a_list)[::2]: >>>... >>> >>> I still think

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-14 Thread Andrew Barnert via Python-ideas
On May 14, 2020, at 10:45, Rhodri James wrote: > > On 14/05/2020 17:47, Andrew Barnert via Python-ideas wrote: >> Which is exactly why Christopher said from the start of this thread, >> and everyone else has agreed at every step of the way, that we can’t >> change

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-14 Thread Andrew Barnert via Python-ideas
nstead of a list. But again, I’m not sure how bad that would be in practice.___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.or

[Python-ideas] Re: Documenting iterators vs. iterables [was: Adding slice Iterator ...]

2020-05-15 Thread Andrew Barnert via Python-ideas
"file") as f: > for line in f: > do_other_stuff(line) > > I don't know, maybe they asked the student next to them. :-) Or they got it off StackOverflow or Python-list or Quora or wherever. Those resources really do occasionally work as intended, pro

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-15 Thread Andrew Barnert via Python-ideas
den? Suddenly > been possessed by the spirits of deceased Java and Ruby programmers > intent on changing the look and feel of Python to make it "real object > oriented"? *wink* No, we have remembered that language design is not made up of trivial rules like “functions

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-15 Thread Andrew Barnert via Python-ideas
the wrapper doesn’t actually type-check that at __new__ time they’d work anyway. But why would anyone, especially when they care about speed, use a generic viewslice function on a numpy array instead of just using numpy’s own view slicing?) It seems like a dunder is something that could be added a

[Python-ideas] Re: Improve handling of Unicode quotes and hyphens

2020-05-15 Thread Andrew Barnert via Python-ideas
ut it will treat an emoji as potentially part of an identifier, so (if that emoji is immediately followed by legal identifier characters, ASCII or otherwise) the caret will show up too far to the right. I’m still glad the Python tokenizer doesn’t do this (because, as I said, I’ve relied on the docum

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-15 Thread Andrew Barnert via Python-ideas
maybe it’s worth putting an implementation on PyPI as soon as possible, so we can get some experience using it and make sure the design doesn’t have any unexpected holes and, if we’re lucky, get some uptake from people outside this thread._______ Pytho

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-15 Thread Andrew Barnert via Python-ideas
s, just like tuple, etc. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/arc

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-16 Thread Andrew Barnert via Python-ideas
methods? > > That's not what I said. Of course Python should have methods -- it's an > OOP language after all, and it's pretty hard to have objects unless they > have behaviour (methods). Objects with no behaviour are just structs. > > But seriously, and this

[Python-ideas] Re: Adding slice Iterator to Sequences (was: islice with actual slices)

2020-05-16 Thread Andrew Barnert via Python-ideas
es (at least not without patching up a whole lot more code than we want). But I’ll try it and see if I’m wrong. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.or

[Python-ideas] Re: [Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-19 Thread Rob Cliffe via Python-ideas
at is wrong (ceteribus paribus) with making it easy for them to do so? ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Me

[Python-ideas] Re: str.strip: argument maxstrip

2020-05-19 Thread Rob Cliffe via Python-ideas
To strip at most 1 character from the end:     txt[:-1] + txt[-1:].rstrip(chars) To strip at most N characters:     txt[:-N] + txt[-N:].rstrip(chars) Given that, I think yours is too much of a niche case to change anything in Python Rob Cliffe On 19/05/2020 12:44, computermaster360 . wrote: I

[Python-ideas] Re: Optional keyword arguments

2020-05-19 Thread Rob Cliffe via Python-ideas
s* multiple ways are allowed as long as there is one clear preference. -- Richard Damon _______ Python-ideas mailing list -- [email protected] <mailto:[email protected]> To unsubscribe send an email to [email protected]

[Python-ideas] Re: Optional keyword arguments

2020-05-19 Thread Rob Cliffe via Python-ideas
On 17/05/2020 20:17, James Lu wrote: Many a python programmer have tired to see code written like: def bar(a1, a2, options=None): if options is None: options = {} ... # rest of function syntax if argument is not passed, evaluate {} and store to options def foo(options

[Python-ideas] Re: [Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-21 Thread Rob Cliffe via Python-ideas
N items".) Whereas doing that with a boolean `strict` would lead, as others have pointed out, to an ugly API (2 booleans that can't both be True). Rob Cliffe ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to p

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-21 Thread Rob Cliffe via Python-ideas
On 21/05/2020 14:50, Steve Barnes wrote: The issue is simple and simple enough for a beginner to fall foul of - test procedure: Change directory to any directory with files in totally a few 10s of megs (ideally but it doesn't matter much). python -m zipfile -c my_zipfile.zip . Wait

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-22 Thread Rob Cliffe via Python-ideas
On 21/05/2020 14:50, Steve Barnes wrote: The issue is simple and simple enough for a beginner to fall foul of - test procedure: Change directory to any directory with files in totally a few 10s of megs (ideally but it doesn't matter much). python -m zipfile -c my_zipfile.zip . Wait

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Rob Cliffe via Python-ideas
. Sounds like a list comprehension: [ needle for needle in haystack if func(needle) ] So maybe one is best... ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.pytho

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-24 Thread Rob Cliffe via Python-ideas
umber keys; that made a real mess of sorting street addresses. How old was your customer? IIRC when I was a child, we had a typewriter that had keys for the digits 2-9, but for 0 and 1 you had to use the above trick. ___ Python-ideas mailing list -- p

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-24 Thread Rob Cliffe via Python-ideas
On 24/05/2020 19:01, David Mertz wrote: The old images I find lack the '1', but not the '0'.  What model was this you had? Sorry, no way I can remember that far back.  I'm not even certain about the missing 0. On Sun, May 24, 2020 at 1:48 PM Rob Cliffe via Python-i

[Python-ideas] Re: Function composition

2020-05-24 Thread Rob Cliffe via Python-ideas
ath' and 'str', then does something with the result and `len'. # Not: first does something with `len' and ... what? Jesus, why is the whole world not using it already? Maybe for the same reason the world still uses QWERTY keyboards. Maybe that's what programmers (we

[Python-ideas] Re: Optional keyword arguments

2020-05-25 Thread Rob Cliffe via Python-ideas
supplied that that was the *wrong* decision. There may have been what seemed good reasons for it at the time (can anyone point me to any relevant discussions, or is this too far back in the Python primeval soup?). But it is a constant surprise to newbies (and sometimes not-so-newbies). As is att

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-25 Thread Rob Cliffe via Python-ideas
drive is very handy.  Could this be another use for it? Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.pyt

[Python-ideas] An HTTP API to list versions of Python

2020-05-26 Thread Julien Palard via Python-ideas
We do not have a standard way to get (programatically) informations about Python versions, this leads to having to commit to numerous places during each releases, and some other places never get the information (like old docs, see [1]). Maybe we should provide an HTTP API listing Python

[Python-ideas] Re: Optional keyword arguments

2020-05-27 Thread Rob Cliffe via Python-ideas
cii(). bool(), callable(), dir(), format(), hash(), help(), isinstance(None, ...) _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-idea

[Python-ideas] Re: Optional keyword arguments

2020-05-27 Thread Rob Cliffe via Python-ideas
ere in memory. It might be created later in foo(), but it would then have a value. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-id

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-27 Thread Rob Cliffe via Python-ideas
On 25/05/2020 15:33, Steven D'Aprano wrote: On Fri, May 22, 2020 at 03:54:30PM +0100, Rob Cliffe via Python-ideas wrote: I find having a RAM drive is very handy.  Could this be another use for it? Could be, if there's a standard way to create a RAM drive on all windows machin

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-30 Thread Rob Cliffe via Python-ideas
al or otherwise, this product or any company or individual that provides it, other than being a satisfied user. Other products are available; I haven't tried any of them so can't comment on them. Rob Cliffe On 28/05/2020 03:00, Ethan Furman wrote: On 05/27/2020 05:53 PM, Rob Cliffe via Pyt

[Python-ideas] Re: Optional keyword arguments

2020-06-02 Thread Rob Cliffe via Python-ideas
m ?= Spam()):         etc. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/lis

[Python-ideas] Shared Semaphores for synchronisation across unrelated processes

2020-06-05 Thread Vinay Sharma via Python-ideas
Hi, Python has integrated shared memory into standard library starting from 3.8 (https://docs.python.org/3/library/multiprocessing.shared_memory.html <https://docs.python.org/3/library/multiprocessing.shared_memory.html>), which provides a user friendly API to access shared memory

[Python-ideas] Re: Shared Semaphores for synchronisation across unrelated processes

2020-06-05 Thread Vinay Sharma via Python-ideas
Hi, As Barry wrote, I am asking for the ability to use shared semaphores in python across unrelated processes. So, that shared memory used across unrelated processes can be synchronised. Although, I am suggesting this only because I am unable to synchronise shared memory across unrelated

[Python-ideas] Re: Shared Semaphores for synchronisation across unrelated processes

2020-06-09 Thread Vinay Sharma via Python-ideas
AM, Vinay Sharma via Python-ideas > wrote: > > Hi, > As Barry wrote, I am asking for the ability to use shared semaphores in > python across unrelated processes. So, that shared memory used across > unrelated processes can be synchronised. > > Although, I am suggesting th

[Python-ideas] Re: Shared Semaphores for synchronisation across unrelated processes

2020-06-09 Thread Vinay Sharma via Python-ideas
the shared memory segment would be much cleaner and easier to do, but unfortunately macos has deprecated sem_t. Other ways include storing an integer in the shared memory segment, which could be altered via atomic operations, this integer can be used as a counting semaphore. Python uses the follo

[Python-ideas] Re: Bringing the print statement back

2020-06-10 Thread Derrick Joseph via Python-ideas
Hi, Just curious, why would bringing back Python 2’s print statement be a good idea? Warm Regards, Sadhana Srinivasan On Wed, Jun 10, 2020 at 2:39 AM, Jonathan Goble wrote: > On Tue, Jun 9, 2020 at 8:08 PM Guido van Rossum wrote: > >> I believe there are some other languages th

[Python-ideas] Re: Bringing the print statement back

2020-06-11 Thread Rob Cliffe via Python-ideas
blank line print # silent failure That's especially going to burn people who remember Python 2, where it did print a blank line instead of evaluating to the `print` object. No problem!  If the new super-duper all-singing-and-dancing-and-make-the-tea parser can cope with 'print&#

[Python-ideas] Re: Bringing the print statement back

2020-06-15 Thread Rob Cliffe via Python-ideas
On 12/06/2020 00:17, MRAB wrote: On 2020-06-11 22:15, Ethan Furman wrote: On 06/11/2020 01:18 PM, Rob Cliffe via Python-ideas wrote: If the new super-duper all-singing-and-dancing-and-make-the-tea parser can cope with 'print' without parens, it can cope with print followed by noth

[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Rob Cliffe via Python-ideas
i in range(10) if i == 5] if a:     print(a) Evaluate: [5] ``` I hope I explained my idea well enough and hope to see something like this in the future. If anyone has questions on my interpretation please ask. ___ Python-ideas mailing list -- python-

[Python-ideas] Allow signal suppression

2020-06-25 Thread Yonatan Zunger via Python-ideas
them from the main thread, if you have potentially critical regions running in any non-main thread, there's no good way for them to tell the main thread to change the handlers... except by sending the main thread a signal. That requires the "suppressing" handler to have nontrivial l

[Python-ideas] Re: Allow signal suppression

2020-06-25 Thread Yonatan Zunger via Python-ideas
Absolutely, but I figured the natural thing to expose from the C API was a very minimal function, and then put a context manager in the Python layer. The actual context manager implementation I would use would be a bit smarter than a bare set/reset -- it would use an unbounded semaphore and only

[Python-ideas] Re: Allow signal suppression

2020-06-25 Thread Yonatan Zunger via Python-ideas
ne of the systems I've do control is the shell that runs cron jobs (not their scheduling, but their actual execution) which needs to provide an outer harness that manages getting commands from the scheduler, integration with all sorts of logging and monitoring systems, etc., and needs to actually

[Python-ideas] Re: Allow signal suppression

2020-06-26 Thread Yonatan Zunger via Python-ideas
Hmm, interesting thought! I'll try that out. Thanks! On Fri, Jun 26, 2020, 01:51 Antoine Pitrou wrote: > On Thu, 25 Jun 2020 18:32:48 -0700 > Yonatan Zunger via Python-ideas > wrote: > > > > So that's an example of why you might find yourself in such a situation

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-06-29 Thread Rob Cliffe via Python-ideas
On 29/06/2020 20:19, Rhodri James wrote: On 29/06/2020 18:42, Stestagg wrote: Several times now, I've had the need to 'just get any key/value' from a large dictionary.  I usually try first to run `var.keys()[0]` only to be told that I'm not allowed to do this, and instea

[Python-ideas] Re: Escapes inside curly braces in f-strings

2020-06-29 Thread Rob Cliffe via Python-ideas
On 29/06/2020 15:29, Mikhail V wrote: Proposal: Allow standard python escapes inside curly braces in f-strings. Main point is to make clear visual distinction between text and escaped chars: # current syntax: print ("\nnewline") print ("\x0aa") # new syn

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-06-30 Thread Rob Cliffe via Python-ideas
erent (apart from binding `i` and `j`) from for item in d.items(): do(item) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/

[Python-ideas] Re: Else assert statement

2020-07-03 Thread Rob Cliffe via Python-ideas
the error message to 'foo must be 1, 2, 3 or 4' but if you look at the code, this is kinda obvious (and if you forget to do it, it's also obvious to someone reading the code). Objection 3: Not worth forcing Python users to learn a new construct for not much benefit.

[Python-ideas] Re: Add builtin function for min(max())

2020-07-05 Thread Rob Cliffe via Python-ideas
't think the new function should be restricted to numbers. There may be uses for strings, or for user-built classes; why restrict it unnecessarily? If it quacks like supporting __lt__ and __gt__, it's a duck. Rob Cliffe ___________ Python-ideas mailing l

[Python-ideas] Re: Add builtin function for min(max())

2020-07-06 Thread Rob Cliffe via Python-ideas
(or both) missing, sometimes not. Rob Cliffe ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add builtin function for min(max())

2020-07-07 Thread Rob Cliffe via Python-ideas
. sets would be unusual and come labelled with "consenting adults, use at own risk". Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.

[Python-ideas] Re: Add builtin function for min(max())

2020-07-09 Thread Ronald Oussoren via Python-ideas
I would not expect `lower` to ever be True or False, I > expect this condition to always fail. Am I missing something? This uses comparison chaining and is equivalent to “lower == upper and upper is not None”. I don’t like this particular style, I had to read this a couple of times to get

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-10 Thread Ronald Oussoren via Python-ideas
hat makes it impossible to use, as an example, a linked list to preserve insertion order. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ <https://blog.ronaldoussoren.net/> _______ Python-ideas mailing list --

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-10 Thread Ronald Oussoren via Python-ideas
iously), so a change to linked-lists would not > change this runtime O characteristic. The current views don’t support indexing at all, that’s the whole point of this thread. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ ____

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-10 Thread Ronald Oussoren via Python-ideas
ould require O(1): I wouldn't want to constrain > any implementation for a niche use case. I agree. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/_______ Python-ideas mailing list -- [email protected] To unsub

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-11 Thread Rob Cliffe via Python-ideas
----- This idea was suggested as enhancement issue (https://bugs.python.org/issue41272). Eric V. Smith (eric.smith) advised me to put this on the python-ideas mailing list (https://bugs.python.org/issue41272#msg373486). ___ Just to

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-17 Thread David Mertz via Python-ideas
xarray greatly. It's also somewhat of an additional novelty added to the proposal that is somewhat independent. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-18 Thread Rob Cliffe via Python-ideas
On 13/07/2020 18:42, Barry Scott wrote: On 13 Jul 2020, at 05:55, Christopher Barker <mailto:[email protected]>> wrote: well, sure, though I have to say that I think that that's an unfortunate confusing thing about python dicts. IN fact, I doubt there are many uses at all

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-20 Thread Rob Cliffe via Python-ideas
and 'if not break:' rather than say 'on_break:' etc. would avoid adding new keywords. I don't know what to do about the zero iterations case, though. Best wishes Rob Cliffe ___ Python-ideas mailing list -- [email protected] T

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-20 Thread Rob Cliffe via Python-ideas
I don't know what to do about the zero iterations case, though. Perhaps simply `if not:' Best wishes Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@python

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-21 Thread Rob Cliffe via Python-ideas
allowed between). It looks like a regular IF, but COND is special. On Sun, Jul 12, 2020, at 00:16, Rob Cliffe via Python-ideas wrote: Something to consider: Would it be legal to mix these CONDs with other conditions in the 'elif' chain? E.g. if break: ... elif x > 0: ...

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-21 Thread Rob Cliffe via Python-ideas
On 20/07/2020 09:56, Alex Hall wrote: On Mon, Jul 20, 2020 at 10:36 AM Rob Cliffe via Python-ideas mailto:[email protected]>> wrote: May I repeat:  Spelling 'if break:' and 'if not break:' rather than say 'on_break:' etc. would avoid ad

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-21 Thread Rob Cliffe via Python-ideas
at it’s due to Knuth and that Raymond said so). I invented it without awareness of prior art, by reasoning about the similarity between IF and WHILE (FOR followed from WHILE). —Guido See Raymond's video "Transforming Code into Beautiful, Idiomatic Python" at https://www.youtube.com/wa

[Python-ideas] Re: add !p to pprint.pformat() in str.format() an f-strings

2020-07-21 Thread Rob Cliffe via Python-ideas
e may even be able to have a static attribute stored to change the various default kwargs of pprint.pformat(). _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mai

[Python-ideas] Re: add !p to pprint.pformat() in str.format() an f-strings

2020-07-21 Thread Rob Cliffe via Python-ideas
a function unless the import could actually be local to the f-string itself, not the surrounding scope (perhaps similar to the way a list comprehension is implemented as a function with its own scope). I don't totally understand these matters, so I may have got something wrong. __

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-21 Thread Rob Cliffe via Python-ideas
On 21/07/2020 22:07, Barry wrote: On 21 Jul 2020, at 18:47, Rob Cliffe via Python-ideas wrote:  On Mon, Jul 20, 2020 at 03:22 Jonathan Fine <mailto:[email protected]>> wrote: This is a continuation of my previous post to this thread. Python's FOR ... ELSE

[Python-ideas] Re: add !p to pprint.pformat() in str.format() an f-strings

2020-07-21 Thread Rob Cliffe via Python-ideas
deficiency in the current pprint.pformat.  The proposal would not change anything here. I'm sure there are others. Could you specify.? I'm not saying I'm +1 on the proposal.  Just that there don't seem to be any insurmountable obstacles to it.  My greatest unease is an i

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-21 Thread Rob Cliffe via Python-ideas
On 22/07/2020 00:29, MRAB wrote: On 2020-07-22 00:02, Rob Cliffe via Python-ideas wrote: On 21/07/2020 22:07, Barry wrote: On 21 Jul 2020, at 18:47, Rob Cliffe via Python-ideas wrote:  On Mon, Jul 20, 2020 at 03:22 Jonathan Fine <mailto:[email protected]>> wrote:    

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-22 Thread Rob Cliffe via Python-ideas
On 22/07/2020 22:22, Chris Angelico wrote: On Thu, Jul 23, 2020 at 7:06 AM João Matos wrote: Hello, Why not just use Raymond's suggestion nobreak as a replacement of the else in loops and deprecate the else in Python 4? There is at least a precedent when not equal <> was de

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-23 Thread Rob Cliffe via Python-ideas
ramming. The upholders of the status quo regularly provide gallant explanations of why "else" is perfectly natural, even intuitive. The fact is, it isn't.  If it were, it wouldn't **need** to be repeatedly explained by gurus to lesser mortals.  I can't think of any othe

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-23 Thread Rob Cliffe via Python-ideas
ogramming. Suggesting (as you seem to be) that a given language feature requires an advanced qualification in English to be understood properly scarcely constitutes an endorsement of said feature. O:-) ___ Python-ideas mailing list -- python

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-25 Thread Rob Cliffe via Python-ideas
On 25/07/2020 07:59, David Mertz wrote: On Thu, Jul 23, 2020, 9:19 PM Rob Cliffe via Python-ideas The upholders of the status quo regularly provide gallant explanations of why "else" is perfectly natural, even intuitive. They remind me of these two mathematicians: M1: T

[Python-ideas] How to prevent shared memory from being corrupted ?

2020-07-26 Thread Vinay Sharma via Python-ideas
egment using both the processes, so for me to prevent any race condition (data corruption), either these operations must be atomic, or I should be able to lock / unlock shared memory segment, which I cannot at the moment. I earlier posted a solution <https://mail.python.org/archives/list/pyt

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-26 Thread Rob Cliffe via Python-ideas
"then" as a placeholder, with the final choice of word to be determined. But I do think this is pretty darn illustrative --'cause I would find "then" even LESS intuitive, and it's a whole new keyword to boot! I'm one of those folks that have been around Python

[Python-ideas] PEP8 update: using typing.TypeVar before function defenition

2020-07-26 Thread Nikita Serba via Python-ideas
suggest to update PEP8, so it'd recommend skipping blank lines in this case. Thank you for your attention and sorry for my bad English. Sincerely yours, Nikita Serba.___ Python-ideas mailing list -- [email protected] To unsubscribe send an

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Vinay Sharma via Python-ideas
s object will also be shared across multiple processes, there must be a safe way to update it. Any thoughts on that ? > On 27-Jul-2020, at 3:50 PM, Robert Collins wrote: > > On Sun, 26 Jul 2020 at 19:11, Vinay Sharma via Python-ideas > wrote: >> >> Problem: >

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-28 Thread Rob Cliffe via Python-ideas
er loop) might be "break all" or "break *". (BTW I have a job lot of bikesheds, in case you want any cheap ones.) So maybe you could give half an eye to not clashing with some such possible future scheme? Rob ___ Python-id

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-30 Thread Vinay Sharma via Python-ideas
ified yet: is 'sync' in the name > implying a mutex, an RW lock, or dependent on pointers to atomic types > (which then becomes a portability challenge in some cases). The C++ > atomics documentation you linked to documents a similar but > differently named set of methods,

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-31 Thread Vinay Sharma via Python-ideas
I think you are talking about shared/named semaphores. The problem with them is that python doesn’t have support for shared semaphores, so the first step would be to build an API providing access to shared semaphores, and then this API can be used to synchronise shared memory. > On 30-Jul-2

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-08-01 Thread Vinay Sharma via Python-ideas
> On 01-Aug-2020, at 1:31 AM, Marco Sulla wrote: > > On Thu, 30 Jul 2020 at 12:57, Vinay Sharma via Python-ideas > mailto:[email protected]>> wrote: > Python has support for atomic types, I guess: > Atomic Int: > https://github.com/python/cpython/b

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-08-02 Thread Vinay Sharma via Python-ideas
The shared memory scheduler has some notable limitations: > > > > - It works on a single machine > > - The threaded scheduler is limited by the GIL on Python code, so if your > > operations are pure python functions, you should not expect a multi-core > > speedup &g

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-08-02 Thread Vinay Sharma via Python-ideas
ultiprocessing.RLock> > On Sat, 1 Aug 2020 at 22:42, Eric V. Smith <mailto:[email protected]>> wrote: > While they're immutable at the Python level, strings (and all other > objects) are mutated at the C level, due to reference count updates. You > need to consider this if yo

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-08-05 Thread Rob Cliffe via Python-ideas
On 29/07/2020 14:51, Ethan Furman wrote: On 7/28/20 10:30 PM, Rob Cliffe via Python-ideas wrote: A possible, unrelated, future language extension is to allow breaking out of more than one loop at a time. I would think that     break would handle that situation. -- ~Ethan~ Maybe.  But

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-08-05 Thread Rob Cliffe via Python-ideas
of syntax will be easier. By the way, the word_count example is as I typed it, but it has a typo. Did you spot it when you read it? (I only noticed it when re-reading my message.) Finally, thank you for your contributions. More examples please. -- Jonathan ______

[Python-ideas] New monotonic clock that tracks across system suspend

2020-08-05 Thread Rishav Kundu via Python-ideas
they track across system suspend or not. These clocks exist on at least Windows, macOS, and Linux. [1] https://www.python.org/dev/peps/pep-0418/#id56 — Rishav P.S.: This is my first time submitting to the Python mailing lists. Suggestions for improvement are appreciated

<    8   9   10   11   12   13   14   15   16   17   >