[Python-ideas] Re: Exception spaces

2020-04-10 Thread Andrew Barnert via Python-ideas
or that your tone doesn’t fit the style or the Python community, or whatever, I don’t think so. Look at the proposal to change variable deletion time—that’s gotten a ton of pushback, and it’s certainly not because nobody respects Guido or nobody likes him. ______

[Python-ideas] Re: Range of Indexes

2020-04-10 Thread Andrew Barnert via Python-ideas
On Apr 10, 2020, at 12:46, Chamoun Saoma wrote: > > I have an idea to improve the python language through the creation of a new > and very readable function. > # > def ranlen(x): > #range of length of x > return range(len(x)) > ###

[Python-ideas] Re: RFC: For Loop Invariants

2020-04-10 Thread Andrew Barnert via Python-ideas
tire new list > before summing. It sounds like you really are just looking for generator expressions, which were added in Python 2.4 a couple decades ago. They have the same syntax as list comprehensions without the square brackets, but they generate one element at a time instead of generati

[Python-ideas] Re: Proposed class for collections: dynamicdict

2020-04-10 Thread Andrew Barnert via Python-ideas
nswer to one of these—although unless that good answer is performance, it seems like this should be a 5-line class in Python, not a custom C class. (Keep in mind that defaultdict was added somewhere around 2.4 or 2.5, while __missing__ has only been there since somewhere around 2.7/3.3. I’ll bet it

[Python-ideas] Re: Exception spaces

2020-04-11 Thread Andrew Barnert via Python-ideas
a return value plus an OK or an Error, you specify either an Ok(return value) or an Err(error value). Sure, technically that’s the same amount of information, but the way it’s done, together with the syntactic sugar provided by the language, makes a big difference, which I’ll get to below. >

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-04-11 Thread Andrew Barnert via Python-ideas
CPython, a new class can have whatever cross-implementation requirements we write into it. You can document that a StringBuilder doesn’t retain all of its input strings, but is at minimum roughly as efficient as making a list of strings and joining them anyway, and every Python implementation will d

[Python-ideas] Re: Range of Indexes

2020-04-11 Thread Andrew Barnert via Python-ideas
e presenting a dynamic Spam* array terminated by a sentinel value), and iteration still works.___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/

[Python-ideas] Re: Proposed class for collections: dynamicdict

2020-04-14 Thread Andrew Barnert via Python-ideas
e, as opposed to in collections or something else in the Data Types chapter in the docs, but that’s true of most of functools, and at least once people discover it (from a Python-list or StackOverflow question or whatever) they’ll learn where it is and be able to use it easily, just like the rest

[Python-ideas] Re: Should dataclass init call super?

2020-04-15 Thread Andrew Barnert via Python-ideas
s extra parameters in -- and the > dataclass' __init__ won't accept extra arguments. Can’t you just create InitVar attributes for the extra args you want to pass through in that case? ___________ Python-ideas mailing list -- [email protected]

[Python-ideas] Re: Should dataclass init call super?

2020-04-15 Thread Andrew Barnert via Python-ideas
the connection between two key components in an air traffic control system, then you probably do want to put in that effort. If it’s an internal class that only gets constructed in one place, in a tool for trolling each other with bad music in the office stereo that only you and three colleag

[Python-ideas] Re: Should dataclass init call super?

2020-04-15 Thread Andrew Barnert via Python-ideas
effort—just make Y pass everything through, and the couple places you end up needing to pass down one of those Pandas-y arguments you just do so, and it works, and that’s fine. ___ Python-ideas mailing list -- [email protected] To unsubscrib

[Python-ideas] Re: TLS session resumption

2020-04-15 Thread Andrew Barnert via Python-ideas
a file to resume the TLS session later on. Please tell me how >> this is done if I'm wrong. > > Not a Python SSL expert, but have you tried pickling the session object? > > If that doesn't work, then I would say that adding pickle support > (using the semantics y

[Python-ideas] Re: Should dataclass init call super?

2020-04-15 Thread Andrew Barnert via Python-ideas
it they could stay as competitors on PyPI forever, while if it turns out that the extension hooks aren’t sufficient, someone could propose exactly what needs to be changed to make the extension writable. _______ Python-ideas mailing list -- python-ideas@pyth

[Python-ideas] Re: Proposed class for collections: dynamicdict

2020-04-15 Thread Andrew Barnert via Python-ideas
any other dunder that is only implicitly called on builtin types? Actually, IIRC, __getattr__ is itself another example. Python never calls __getattr__, only __getattribute__. However, object.__getattribute__ (and type.__getattribute__) calls __getattr__ on failure, the exact same way dict.__

[Python-ideas] Re: collections.UpdateDict, collections.InsertDict, collections.InsertOrIgnoreDict

2020-04-16 Thread Andrew Barnert via Python-ideas
that, in idiomatic and readable code (and in fact with variations—update, |, or ChainMap); why would I want to be able to write the same thing in another way that’s conceptually backward, probably less efficient, and doesn’t work in Python 3.8? If the issue is just that you have those default va

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-16 Thread Andrew Barnert via Python-ideas
either one of them…) _______ 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

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-16 Thread Andrew Barnert via Python-ideas
way or not. And even if it does, that hurdle of describing the syntax in a way that people won’t get confused the way they do when they first learn the feature in C++ might be hard to overcome. But it’s at least plausible that it could be readable and learnable enough. ______

[Python-ideas] Re: Proposed class for collections: dynamicdict

2020-04-16 Thread Andrew Barnert via Python-ideas
place where it gets complicated, but there may be others I haven’t remembered. I can dig this up if you‘re interested. Maybe it’s even worth cleaning up and posting to PyPI, or even proposing for somewhere in the stdlib (collections or functools?). ___

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-16 Thread Andrew Barnert via Python-ideas
(And I like the overall idea in this thread if someone can come up with good enough syntax.) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org

[Python-ideas] Re: Proposed class for collections: dynamicdict

2020-04-16 Thread Andrew Barnert via Python-ideas
Mapping…). Whether that counts as an argument for or against any version of the various proposals in this thread, I’m not sure. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected]

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-16 Thread Andrew Barnert via Python-ideas
On Apr 16, 2020, at 20:48, [email protected] wrote: > > In Javascript ES6 they don't have sets built like python so `{}` always > refers to objects being constructed. It does indeed support implicit key: > value pairs, so in ES6 `{ a: a, b: x, c: c }` is equivalent

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
d I think better, way. > But implementing this change with the argument of making function calls less > repetitive or verbose when having redundant named keywords and variables > doesn't sell it to me. > > See, function calls would still suffer to be less redundant if we go with

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
> On Apr 17, 2020, at 01:58, Steven D'Aprano wrote: > > On Thu, Apr 16, 2020 at 09:21:05PM -0700, Andrew Barnert via Python-ideas > wrote: > >> But I don’t see why that rules out the “bare colon” form that I and >> someone else apparently both proposed

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
inly fluent) speakers of a LTR-written language (as were the designers of Lisp, most of the C committee, etc.). If Steve has a problem reading it, I think it’s probably just him, but of course if I’m wrong I hope (and expect) others will chime in. ___ P

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
ing in that case. I’m not sure how much that parallel means (or even what it would imply if it did mean a lot). I think I’m still -0.5, and the fact that you can get the same effect if you’re willing to use CPython frame hacks doesn’t make me either more or less negative. ___

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
ot other uses of **unpacking, or having a mode switch in the middle of call syntax, or anything else proposed so far.) ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.py

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
On Apr 17, 2020, at 13:12, David Mertz wrote: > > However, proposals for symbols in Python *do* pop > up from time to time, so this would perhaps make such a thing harder if > it ever becomes desired (which is unlikely, but possible). Sure. It would also conflict with Nick Coghlan’

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Andrew Barnert via Python-ideas
ort of get the hang of doing, which is not usually what you’re aiming for with a language feature. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mai

[Python-ideas] Re: Proposal: Keyword Unpacking Shortcut [was Re: Keyword arguments self-assignment]

2020-04-18 Thread Andrew Barnert via Python-ideas
additional syntax with a different meaning in just one specific context, calls, that’s not legal in the others. Each special case like that makes the language’s syntax a little harder to internalize, and it’s a good thing that Python has a lot fewer such special cases than, say, C. Worse, this

[Python-ideas] Re: Proposal: Keyword Unpacking Shortcut [was Re: Keyword arguments self-assignment]

2020-04-18 Thread Andrew Barnert via Python-ideas
exception adds a small cost to learning the language, but Python doesn’t have to be perfectly regular like Lisp or Smalltalk, it just has to be a lot less irregular than C or Perl. Most special cases aren’t special enough, but some are. A subscription looks like a list display, but it’s not. Mi

[Python-ideas] Re: list.append(x) could return x

2020-04-20 Thread Andrew Barnert via Python-ideas
On Apr 20, 2020, at 08:41, J. Pic wrote: > > > Currently, list.append(x) mutates the list and returns None. Yes, which is consistent with the vast majority of mutating methods in Python. It would be pretty weird to make lst.append(x) return x, while lst.extend(xs) still returns Non

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Andrew Barnert via Python-ideas
On Apr 20, 2020, at 01:06, M.-A. Lemburg wrote: > > The current version already strikes me as way too complex. > It's by far the most complex piece of grammar we have in Python: > > funcdef: 'def' NAME parameters ['->' test] ':' [TYPE_COMMEN

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
o be added as a flag on the builtin. _______ 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.py

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Andrew Barnert via Python-ideas
On Apr 20, 2020, at 11:01, Christopher Barker wrote: > > The JSON - related example is a good one -- JSON maps well to "data" in > Python, dicts and lists of numbers and strings. If you find yourself > converting a bunch of variable names to/from JSON, you probably shoul

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
ould be a better design if you were doing Python from scratch, but I think the established existence of zip_longest pushes us the other way. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@p

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
On Apr 20, 2020, at 13:03, Eric V. Smith wrote: > > On 4/20/2020 3:39 PM, Andrew Barnert via Python-ideas wrote: >> >> >> As I said, wanting to check does come up sometimes—I know I have written >> this myself at least once, and I’d be a little surprised if

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
matter if you zip(y, x, strict=True) instead? _______ 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 ht

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Andrew Barnert via Python-ideas
it’s a declarative format, it’s just that often it’s intended to be understood as representing an object graph. > In Python, you need to decide how you want to work with it, either as an > object with attributes or a dict. But if you are getting it from JSON, it's a > dict to begin

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
new strict=True/zip_strict/zip_equal) is probably not a great tragedy. _______ 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/archive

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
y even with `strict=True`" out loud; maybe that's a mild argument for using a different qualifier like `equal`, as in more-itertools?) ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@pyt

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Andrew Barnert via Python-ideas
marginal benefit. That’s why I think the whole proposal is marginal. It’s almost never going to be a huge win—but it may be a small win in so many places that it adds up to being worth it. ___ Python-ideas mailing list -- [email protected]

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Andrew Barnert via Python-ideas
On Apr 20, 2020, at 16:24, M.-A. Lemburg wrote: > > On 20.04.2020 19:43, Andrew Barnert via Python-ideas wrote: >>> On Apr 20, 2020, at 01:06, M.-A. Lemburg wrote: >>> >>> The current version already strikes me as way too complex. >>> It's by f

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Andrew Barnert via Python-ideas
> On Apr 20, 2020, at 17:22, Steven D'Aprano wrote: > > On Mon, Apr 20, 2020 at 03:28:09PM -0700, Andrew Barnert via Python-ideas > wrote: > >> Admittedly, such cases are almost surely not that common, but I >> actually have some line-numbering code that did so

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-21 Thread Andrew Barnert via Python-ideas
On Apr 21, 2020, at 01:27, M.-A. Lemburg wrote: > > On 21.04.2020 04:25, Andrew Barnert via Python-ideas wrote: >>> On Apr 20, 2020, at 16:24, M.-A. Lemburg wrote: >>> >>> On 20.04.2020 19:43, Andrew Barnert via Python-ideas wrote: >>>>>

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-21 Thread Andrew Barnert via Python-ideas
On Apr 21, 2020, at 01:36, Serhiy Storchaka wrote: > > 20.04.20 23:33, Andrew Barnert via Python-ideas пише: >> Should this print 1 or 2 or raise StopIteration or be a don’t-care? >> Should it matter if you zip(y, x, strict=True) instead? > > It should print 2 in bot

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-21 Thread Andrew Barnert via Python-ideas
th it. ___ 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/list/[email protected]/m

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-22 Thread Andrew Barnert via Python-ideas
proselytize for the next one. If you can convince lots of people that they should care about the choice more often and get them using the explicit functions, it’ll be a lot harder to argue that everyone is happy with today’s behavior. _______ Python-ideas mai

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-22 Thread Andrew Barnert via Python-ideas
and counter start from zero by > default. I would have asked you why you were counting your lines > starting from zero instead of using `enumerate(xs, 1)` but I thought > that was intentional. You were right, counting from 0 was intentional. Just as it is almost everywhere in Python. Th

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-22 Thread Andrew Barnert via Python-ideas
> On Apr 21, 2020, at 16:02, Steven D'Aprano wrote: > > On Tue, Apr 21, 2020 at 12:25:06PM -0700, Andrew Barnert via Python-ideas > wrote: >>> On Apr 21, 2020, at 01:36, Serhiy Storchaka wrote: >>> except ValueError: # assuming that’s the excepti

[Python-ideas] Re: Add extend_const action to argparse

2020-04-22 Thread Andrew Barnert via Python-ideas
d by extend. And of course you’re adding extend_const. I don’t know if that’s worth fixing separately, but if not it seems to me it’s probably worth fixing in your patch. ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-23 Thread Andrew Barnert via Python-ideas
> On Apr 22, 2020, at 14:09, Steven D'Aprano wrote: > > On Wed, Apr 22, 2020 at 10:33:24AM -0700, Andrew Barnert via Python-ideas > wrote: > >> If that is your long-term goal, I think you could do it in three steps. > > I think the first step is a PEP. This i

[Python-ideas] Re: Make type(None) the no-op function

2020-04-24 Thread Andrew Barnert via Python-ideas
even after you figure it out, it would hardly be any more obvious to other people who need a noop function where to go digging for it than it was for you. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ide

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-24 Thread Andrew Barnert via Python-ideas
ved that problem, and now everyone can stop talking past each other. (Although the couple of people who suggested wanting to _handle_ the error as a normal case rather than treating it as a logic error to debug like your examples still need to give use cases if they want anything different th

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-25 Thread Andrew Barnert via Python-ideas
On Apr 25, 2020, at 09:40, Christopher Barker wrote: > > - The main exception to this may be when one of them is infinite, but how > common is that, really? Remember that when zip was first created (py2) it was > a list builder, not an iterator, and Python itself was much less

[Python-ideas] Re: Adding a "once" function to functools

2020-04-26 Thread Andrew Barnert via Python-ideas
on. This includes the really trivial case where you know what’s needed before you fork any threads that might need it (although for a lot of those cases, in Python, it’s probably simpler to just use a module global, but using an unsynchronized cache isn’t terrible for readability). Of course it’s

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-26 Thread Andrew Barnert via Python-ideas
On Apr 26, 2020, at 14:36, Daniel Moisset wrote: > > This idea is something I could have used many times. I agree with many people > here that the strict=True API is at least "unusual" in Python. I was thinking > of 2 different API approaches that could be used for t

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-27 Thread Andrew Barnert via Python-ideas
On Apr 26, 2020, at 16:58, Steven D'Aprano wrote: > > On Sun, Apr 26, 2020 at 04:13:27PM -0700, Andrew Barnert via Python-ideas > wrote: > >> But if we add methods on zip objects, and then we add a new skip() >> method in 3.10, how does the backport work? It

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-27 Thread Andrew Barnert via Python-ideas
not possible (and hence we may have done some work that we want to > "roll-back" in some sense). Agreed. But here’s a different way to look at it: The Python iteration protocol hides the difference between different kinds of iterables; every iterator is just a dumb next-only

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-27 Thread Andrew Barnert via Python-ideas
is a lot shorter, easier to understand, harder to get wrong, and more flexible (e.g., it works unchanged with any number of iterables, while yours to had to rewritten for any different number of iterables because it requires N! chunks of explicit boilerplate). Are there any examples where it lets yo

[Python-ideas] Smarter zip, map, etc. iterables (Re: Re: zip(x, y, z, strict=True))

2020-04-27 Thread Andrew Barnert via Python-ideas
ABC: filter can _never_ preserve Sized but can _always_ preserves Reversible, etc. This is clearly feasible—Swift does it, and C++ is trying to do it in their next version, and Python already does it in a few special cases (as mentioned earlier), just not in all (or even most) of the potent

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-27 Thread Andrew Barnert via Python-ideas
by using numpy. > I haven't found a real use-case for this yet, tho. > SIMD is handled by numpy, which does a better job than you could ever hope > for in plain python, and for SIMD you could use zip_longest with a suitable > dummy instead. but... yeah, not really useful.

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-27 Thread Andrew Barnert via Python-ideas
ok at proprietary code > so I post about stuff in the hopes that the ppl who can will back this stuff > up. > > (doesn't proprietary software make things so much harder? :/) A little bit, but not nearly as much as you seem to be thinking. There are zillions of lines of open so

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-27 Thread Andrew Barnert via Python-ideas
re of a rationale than “let’s say you want to intermingle the bits of two 16-bit integers into a 32-bit integer”. Sure, that’s something that’s easy to do in some other languages (it’s the builtin $ operator in INTERCAL) but very hard to do readably or efficiently in Python. If we added a $ oper

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-27 Thread Andrew Barnert via Python-ideas
or more powerful? > > the only one with equivalent semantics is the last one. I won’t argue about whether two functions that give the exact same results in every case but get there in different ways are “equivalent” or not, since one is already good enough. If you agree that there is obvi

[Python-ideas] Re: Adding a "once" function to functools

2020-04-28 Thread Andrew Barnert via Python-ideas
one else is missing. To the user of this module, this really should look like a variable, not a function. The fact that we want to initialize it later shouldn’t change that. Especially not in Python—other languages bend over backward to make you write getters around every public attribute even

[Python-ideas] Re: extended for-else, extended continue, and a rant about zip()

2020-04-28 Thread Andrew Barnert via Python-ideas
ind of the opposite of fun. :) ___ 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.pyth

[Python-ideas] Re: Adding a "once" function to functools

2020-04-28 Thread Andrew Barnert via Python-ideas
On Apr 28, 2020, at 12:02, Alex Hall wrote: > > Some libraries implement a 'lazy object' which forwards all operations to a > wrapped object, which gets lazily initialised once: > > https://github.com/ionelmc/python-lazy-object-proxy > https://docs.djangoprojec

[Python-ideas] Re: Adding a "once" function to functools

2020-04-29 Thread Andrew Barnert via Python-ideas
access the value is probably even less acceptable when unnecessary. So, I think it makes sense to leave it up to the user (but to explain the issue in the docs). Or maybe we could add a threading.once (and asyncio.once?) as well as functools.once? ___________ Pyt

[Python-ideas] Re: deque: Allow efficient operations

2020-04-29 Thread Andrew Barnert via Python-ideas
ode before the splice point (or, for doubly-linked, after is fine too). Another reason to use (Lisp/Haskell-style) linked lists is that they automatically release nodes as you iterate unless you keep a reference to the head, but that’s clumsy to do with P

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-29 Thread Andrew Barnert via Python-ideas
olves half of those problems (as long as “longest” is one of the options), but it makes others even worse. The available strings aren’t even discoverable as part of the signature, auto-complete won’t help at all, and the result is even longer and even more deemphasizes the important thing. __

[Python-ideas] Re: deque: Allow efficient operations

2020-04-29 Thread Andrew Barnert via Python-ideas
le (and the tutorial?) could both just have a sentence saying “Python doesn’t have a linked list type because there are so many useful kinds of linked lists and they’re all easy to build but very different—see the Linked Lists HOWTO for details.” But if I wrote it, it would probably be 4x as long as a

[Python-ideas] Re: Adding a "once" function to functools

2020-04-29 Thread Andrew Barnert via Python-ideas
ght the first time, rather than repeating the same mistake. Is there anything about Python’s memory model guarantee that means it can’t happen in Python? I don’t think there _is_ a memory model. In CPython, or any GIL-based implementation, I _think_ it’s safe (the other thread can’t be running at th

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-30 Thread Andrew Barnert via Python-ideas
e first one, it’ll be just as easy to figure out that zip_equal is what they’re looking for from the second. Of course it might be better to rewrite the whole thing to be more novice-friendly and to describe what zip iterates at a higher level instead of describing how its __next__ method oper

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-30 Thread Andrew Barnert via Python-ideas
On Apr 29, 2020, at 22:50, Stephen J. Turnbull wrote: > Andrew Barnert via Python-ideas writes: > >>> Also -1 on the flag. > > Also -1 on the flag, for the same set of reasons. > > I have to dissent somewhat from one of the complaints, though: > >> auto

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 08:08, Christopher Barker wrote: > > Also please keep in mind that the members of this list, and the python-dev > list, are not representative of most Python users. Certainly not beginners > but also many (most?) fairly active, but more "casual" use

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Andrew Barnert via Python-ideas
exactly what should be changed and where. _______ 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://m

[Python-ideas] Re: is a

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 10:27, gbs--- via Python-ideas wrote: > > In cases where it makes sense to do explicit type checking (with ABCs or > whatever), I really detest the look of the isinstance() function. > > if isinstance(thing, Fruit) and not isinstance(thing, Apple): >

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

2020-05-01 Thread Andrew Barnert via Python-ideas
ty libraries immediately, as long as there’s an available backport (whether that’s more-iterools, or a trivial zip39 or whatever) that they can require; a flag can’t be used in libraries until they’re able to require Python 3.9 (unless they want to use a backport that monkey patches or shadows the bu

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Andrew Barnert via Python-ideas
mplies that you were right about the best way to get anything done. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Messa

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 16:32, Steven D'Aprano wrote: > > On Fri, May 01, 2020 at 12:28:02PM -0700, Andrew Barnert via Python-ideas > wrote: >>> On May 1, 2020, at 09:24, Christopher Barker wrote: >>> Maybe it's too late for this, but I would love it

[Python-ideas] Re: is a

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 15:35, Steven D'Aprano wrote: > > but if it is all functions, then I think you have no choice but to > either live with it or shift languages, because the syntax for functions > is too deeply baked into Python to change now. Actually, I’m pretty sure Pytho

[Python-ideas] Re: Adding a "once" function to functools

2020-05-01 Thread Andrew Barnert via Python-ideas
r PyPy-STM, or a future GIL-less Python? > > While I truly do appreciate your feedback on this idea, I’m really not clear > on your line of reasoning here. What specifically do you propose would be the > issue with the *Python* implementation? Are you proposing that under some

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-05-08 Thread Andrew Barnert via Python-ideas
ount of stuff to learn in builtins just as much as another function would. And so on. So it’s only worth doing for really special cases, like open. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ide

[Python-ideas] Re: Auto-assign attributes from __init__ arguments

2020-05-08 Thread Andrew Barnert via Python-ideas
eshedding issues (which you already raised), not serious objections to considering them parallel. And I think all of the other differences are either irrelevant, or obviously compelled by differences between the languages (e.g., Python doesn’t need a rule for how it’s different between the

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Andrew Barnert via Python-ideas
a cache key. You need a hashable sequence of the same values. And the way to spell that in Python is tuple. And that’s not a design flaw in Python, it’s a feature. (Shimmer is a floor wax _and_ a dessert topping!) Sure, when you see a tuple, the default first guess is that it’s an anonymous

[Python-ideas] Re: General methods

2020-05-08 Thread Andrew Barnert via Python-ideas
em). >> If it is set, the check for the type of self will be omitted, and you >> can pass an arbitrary object as the first argument of the unbound method. > > Does this effect code written in Python? As I understand, in Python > code, unbound methods are just plain old func

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

2020-05-08 Thread Andrew Barnert via Python-ideas
ated textbooks. Which is pretty odd. [4] Or even later, after giving the same spatial boundaries, then the same temporal boundaries, then the math/logic definition, but I’m lumping those all together as one sense because they’re coextensive if spacetime Is topological. :) ___

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Andrew Barnert via Python-ideas
On May 8, 2020, at 20:36, Dan Sommers <[email protected]> wrote: > > On Fri, 8 May 2020 17:40:31 -0700 > Andrew Barnert via Python-ideas wrote: > >> So, the OP is right that (1,2,3)==[1,2,3] would sometimes be handy, >> the opponents ar

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-05-09 Thread Andrew Barnert via Python-ideas
> On May 9, 2020, at 04:30, Alex Hall wrote: >  >> On Fri, May 8, 2020 at 11:22 PM Andrew Barnert via Python-ideas >> wrote: > >> Trying to make it a flag (which will always be passed a constant value) is a >> clever way to try to get the

[Python-ideas] Re: zip() as a class constructor (meta) [was: ... Length-Checking To zip]

2020-05-09 Thread Andrew Barnert via Python-ideas
imilar to a class with __next__, send, throw, and close methods. But that doesn’t really change your point. For a different angle on this: What If Python 3.10 changed things so that every generator function actually did define a new class (maybe even accessible as a member of the function)? What

[Python-ideas] Re: islice with actual slices

2020-05-09 Thread Andrew Barnert via Python-ideas
ly did turn out to be occasionally useful.)___________ 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-09 Thread Andrew Barnert via Python-ideas
On May 9, 2020, at 12:38, Christopher Barker wrote: > > https://github.com/PythonCHB/islice-pep/blob/master/pep-xxx-islice.rst I haven’t read the whole thing yet, but one thing immediately jumped out at me: > and methods on containers, such as dict.keys return iterators in Python 3,

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-09 Thread Andrew Barnert via Python-ideas
ight place for it. I have a similar “lexicompare” in my toolbox, but it has extra options that YAGNI. Anyway, even if I’m remembering right, you probably don’t need to dig up the more-itertools PR because it’s easy enough to redo from scratch.) ___ Python-id

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-09 Thread Andrew Barnert via Python-ideas
==y for x,y in zip_longest(self.it, other, fillvalue=object())) def __lt__(self, other): for x, y in zip_longest(self.it, other, fillvalue=_Smallest()): if x < y: return True elif x < y: return False return False __

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

2020-05-09 Thread Andrew Barnert via Python-ideas
> > > and methods on containers, such as dict.keys return iterators in Python 3, > > No they don’t. They return views—objects that are collections in their own > right (in particular, they’re not one-shot; they can be iterated over and > over) but just delegate to a

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

2020-05-09 Thread Andrew Barnert via Python-ideas
On May 9, 2020, at 17:35, Steve Jorgensen wrote: > > I believe the Python standard library should include a means of sanitizing a > filesystem entry, and this should not be something requiring a 3rd party > package. > > One of reasons I think this should be in the stand

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

2020-05-10 Thread Andrew Barnert via Python-ideas
worth it, and that any form of this proposal would make it even rarer, but I could be wrong. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman

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

2020-05-10 Thread Andrew Barnert via Python-ideas
27;, '6', '7', '8', '9'] You just picked an example where “resettable iterator” and “collection” would do the same thing. Try the same test with list and it also passes, because list is a collection. You can only distinguish the two cases by partially using a

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

2020-05-10 Thread Andrew Barnert via Python-ideas
acters in other error messages when they come directly from the user’s input text. For example, if I try to 2+Spám(), the error message will have á in the string.) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to pyth

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

2020-05-10 Thread Andrew Barnert via Python-ideas
ten or fixed manually, and that’ll show you”, we can tell them “Use a proper editor in the future, but meanwhile you can fix your existing script with `python -m defancier -f script.py`“. And a simple IDE or editor mode that doesn’t want to come up with something better could run defanc

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