[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-03 Thread Andrew Barnert via Python-ideas
xz_stuff(x, z) … would be roughly equivalent to: try: x, 0, z = vec except ValueError. pass else: xz_stuff(x, z) What you’ve given is a way to put code in the one place where we didn’t want any (but had to put a “pass” just for syntactic reasons) without putt

[Python-ideas] Re: concurrent.futures cancel pending at Executor.shutdown

2020-01-03 Thread Andrew Barnert via Python-ideas
ldren telling them to finish as quickly as possible, then wait for them to finish. If you’re looking for a way to do a “graceful shutdown if possible but after N seconds just go down hard” the way, e.g., Apache or nginx does, I don’t think that could be safely done killing child threads in P

[Python-ideas] Re: Python, Be Bold!

2020-01-03 Thread Andrew Barnert via Python-ideas
> Ideally, we'd have a functional package manager: one that can delete binaries > when disk space is running low, and recompiles from sources when the binary > is needed again. It could store Python 2 as a series of diffs against Python > 3. I’m not sure why you want to store

[Python-ideas] Re: concurrent.futures cancel pending at Executor.shutdown

2020-01-03 Thread Andrew Barnert via Python-ideas
what multiprocessing.dummy.Pool.terminate (+ join after) does. IIRC, it only does that by accident, because dummy.Process.terminate is a no-op, and that isn’t documented but just happens to be what CPython does. ___ Python-ideas mailing list --

[Python-ideas] Re: Python, Be Bold!

2020-01-05 Thread Andrew Barnert via Python-ideas
On Jan 5, 2020, at 00:17, James Lu wrote: > >  > I use macOS, and using Python is very confusing. > > - Apple's bundled Python 2.7. Apple has made a mess of things, but they’ve actually fixed that mess in 10.15—they now give you 3.7 and 2.7, and neither one is broken o

[Python-ideas] Re: Python, Be Bold!

2020-01-06 Thread Ronald Oussoren via Python-ideas
> On 5 Jan 2020, at 22:41, Andrew Barnert via Python-ideas > wrote: > > On Jan 5, 2020, at 00:17, James Lu wrote: >> >>  >> I use macOS, and using Python is very confusing. >> >> - Apple's bundled Python 2.7. > > Apple has made a me

[Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Andrew Barnert via Python-ideas
have any idea who to trust to get it right.) ___________ 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://

[Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Andrew Barnert via Python-ideas
A package manager like Homebrew or Choco can take care of that by just making my app’s package depend on the PortAudio package (and maybe even conda can?), but I don’t see how zipapps with wheels in, or anything else self-contained, can. And if most such packages eventually migrate to binding fro

[Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Andrew Barnert via Python-ideas
wnloading a Mac-specific py2app app or something else that will definitely work instead of only maybe working and otherwise punting on it as a user problem that I have to figure out how to solve myself? The fact that I can copy that same zipapp to a Windows box and then figure out how to so

[Python-ideas] Re: Recommend UTF-8 mode on Windows

2020-01-10 Thread Andrew Barnert via Python-ideas
On Jan 10, 2020, at 03:45, Inada Naoki wrote: > > Hi, all. > > I believe UTF-8 should be chosen by default for text encoding. Correct me if I’m wrong, but I think in Python 3.7 on Windows 10, the filesystem encoding is already UTF-8, and the stdio console files are UTF-8 (b

[Python-ideas] Re: python -m quality of life improvements

2020-01-10 Thread Andrew Barnert via Python-ideas
On Jan 10, 2020, at 20:40, Steven D'Aprano wrote: > > On Fri, Jan 10, 2020 at 11:53:10PM -0300, Soni L. wrote: >> currently python -m requires you to cwd to the desired package root. I'd >> like to suggest the ability to python -m >> relative/path/to/packag

[Python-ideas] Re: python -m quality of life improvements

2020-01-11 Thread Andrew Barnert via Python-ideas
On Jan 11, 2020, at 14:09, Soni L. wrote: > >  why are we allowed to have fancy `python /path/to/foo.py` but not fancy > `python -m /path/to/foo`? There’s nothing fancy about the first one. It’s a path, and it’s up to your OS what a path means. It’s exactly the same as passing a p

[Python-ideas] Re: python -m quality of life improvements

2020-01-12 Thread Andrew Barnert via Python-ideas
an appropriate setup.py is trivial (and when it isn’t—e.g., because you need to dynamically generate some Cython code and compile it—it’s still usually simpler than any other way to get the code to run). Refusing to use it because it has options you aren’t using is like refusing to use the

[Python-ideas] Re: Recommend UTF-8 mode on Windows

2020-01-13 Thread Andrew Barnert via Python-ideas
uot;iconv -f shift_jis -t utf-8" on > all the .txt files in sight. That WFM (well, I had to do a few .tex > and .rst files too ;-), but most people are dependent on Word, Excel, > and other application formats, and it's a PITA But those are binary formats, not something you can

[Python-ideas] Re: Improve SyntaxError for obvious issue:

2020-01-14 Thread Andrew Barnert via Python-ideas
se are probably the only cases you need to heuristically improve the error handling. You could even maybe do a quick & dirty proof of concept in Python in an import hook, if you don’t want to dive into the middle of the C compiler code. As an alternative, there are lots of projects to use more pow

[Python-ideas] Re: Suggestion for language addition

2020-01-16 Thread Rob Cliffe via Python-ideas
On 04/12/2019 23:41:19, Andrew Barnert via Python-ideas wrote: On Dec 4, 2019, at 12:14, Mike Miller wrote:  On 2019-12-04 11:05, David Mertz wrote: I've often wanted named loops. I know approaches to this have been proposed many times, and they all have their own warts. E.g. an a

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
On Jan 19, 2020, at 12:15, David Mertz wrote: > > In contrast, in pure Python, most of that you do is in loops over the > elements of collections. In that case is does a good job of drawing your eye > to the fact that a method is called but not assigned to anything.

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
ngs: > > result = mystring.upper().strip().center(width).encode('utf-8') > > and nobody blinks an eye or calls it unpythonic. It’s not even immutable that’s the key thing here, but nonmutating. Even on mutable types, Python encourages you to chain up nonmutating oper

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
r, but it has advantages like working automatically for packages installed as zip files, and can be easily extended to do things like i18n- or platform-driven different versions of files, and it works with existing Python. Meanwhile, if that’s not appropriate or not good enough somehow, couldn’

[Python-ideas] Re: List - append

2020-01-19 Thread Andrew Barnert via Python-ideas
t more reliably then. Similarly, in the async > world, there's a common mistake where users write `foo()` rather than `await > foo()`, and that behavior would have caught such bugs. > > Now we can't even flag such things statically (e.g. in mypy) because people > might compla

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
an be easily extended to do things like i18n- >> or platform-driven different versions of files, and it works with existing >> Python. >> >> Meanwhile, if that’s not appropriate or not good enough somehow, couldn’t >> you do what you want without any new syntax?

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-19 Thread Andrew Barnert via Python-ideas
of the import, which inherently >> means it’s an expression. Statements don’t have values. Neither do >> conversion specifiers, or random fragments of syntax. Only expressions have >> values. > > It wouldn't be an expression in itself, it would be an e

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-21 Thread Andrew Barnert via Python-ideas
contents of spam.eggs bound to a variable named eggs (and cached, unless you deliberately circumvent that). It would be using the import statement as an import statement. I even suggested that if you put the import hook on PyPI and show people using it, you could propose adding it to Python, but you

[Python-ideas] Re: List - append

2020-01-21 Thread Andrew Barnert via Python-ideas
l false positives are incredibly rare compared to mistakes. When I said linters and static analyzers I meant linters and linter-like static analyzers like clang-analyze, not linters and compiler/prover-like static analyzers like mypy. I can see why that was misleading, because Python has none

[Python-ideas] Re: Resource imports (as strings/bytes)

2020-01-21 Thread Andrew Barnert via Python-ideas
On Jan 21, 2020, at 09:13, Christopher Barker wrote: > > For (2) — see above— I want the relevant Python object, not just the string > or bytes. A good example of this is the utilities (img2py I think) that come > with wxPython: They bundle up a set of images into a Python

[Python-ideas] Re: addition of "nameof" operator

2020-01-21 Thread Andrew Barnert via Python-ideas
On Jan 21, 2020, at 10:48, Johan Vergeer wrote: > > I have worked with both C# and Python for a while now and there is one > feature of C# I'm missing in the Python language. > > This feature is the "nameof" operator. > (https://docs.microsoft.com/en-us

[Python-ideas] Re: addition of "nameof" operator

2020-01-21 Thread Andrew Barnert via Python-ideas
On Jan 21, 2020, at 13:32, Andrew Barnert wrote: > > On Jan 21, 2020, at 10:48, Johan Vergeer wrote: >> >> def __repr__(self): >> return f"{nameof(Person)}({nameof(self.name)}: {self.name}, >> {nameof(self.age)}: {self.age})" > > W

[Python-ideas] Re: __repr__ helper(s) in reprlib

2020-01-21 Thread Andrew Barnert via Python-ideas
w__. If every param has an attribute with the same name, use that; otherwise, this doesn’t work. And if none of the automatic ways worked and you tried to use them anyway, you get an error. But it would be nice if this error were at class-defining time rather than at repr-calling time, so ma

[Python-ideas] Re: __repr__ helper(s) in reprlib

2020-01-21 Thread Andrew Barnert via Python-ideas
ust doesn’t work. >> >> You could also look at the inspect.signature of __init__ and/or __new__. If >> every param has an attribute with the same name, use that; otherwise, this >> doesn’t work. >> >> And if none of the automatic ways worked and you tried to u

[Python-ideas] Re: docstring for dataclass fields

2020-01-22 Thread Andrew Barnert via Python-ideas
have code to generate help for a module that includes all of its attributes. That doesn’t make sense for class instances in general, but it does make sense for dataclass instances. And extending it to also include some string for each one makes sense. I wouldn’t be surprised if such things already

[Python-ideas] pickle.reduce and deconstruct

2020-01-23 Thread Andrew Barnert via Python-ideas
t _should_ be documented, because it changes every so often, and for good reasons; we don't want anyone writing third-party code that relies on those details. Plus, a different Python implementation might conceivably do it differently. Public helpers exposed from `pickle` itself won'

[Python-ideas] Re: Compound statement colon (Re: Re: Improve SyntaxError for obvious issue:)

2020-01-28 Thread Rob Cliffe via Python-ideas
On 16/01/2020 18:14:18, Random832 wrote: On Tue, Jan 14, 2020, at 18:15, David Mertz wrote: For what it's worth, after 20+ years of using Python, forgetting the colon for blocks remains the most common error I make by a fairly wide margin. Of course, once I see the error message—even

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2020-01-28 Thread Rob Cliffe via Python-ideas
: { make_the_call_happen(); break; } } Relying on fall-through in a switch is a micro-optimisation that may help make things go faster in C, but not so much in Python, so trying to find a literal translation is probably wrongheaded. I would be inclined to separate it into two independent cases

[Python-ideas] Re: addition of "nameof" operator

2020-01-30 Thread Andrew Barnert via Python-ideas
ct of type int that’s probably the same object that’s referenced in dozens of other places, both named and anonymous, in your program’s current state. It can’t possibly have the name “bar”. What _can_ have the name “bar” is the variable that references that value. But that variable isn’t a thing tha

[Python-ideas] Re: addition of "nameof" operator

2020-01-31 Thread Andrew Barnert via Python-ideas
On Jan 31, 2020, at 08:03, Soni L. wrote: > > Consider: > > x=nameof(foo.bar) > > in today's python becomes: > > foo.bar > x="bar" > > and when running this you get an AttributeError or something. > > the benefit is that "bar"

[Python-ideas] Re: addition of "nameof" operator

2020-01-31 Thread Andrew Barnert via Python-ideas
hat it compile to the same thing as the code as you gave, people >> could figure it out, but it still seems both weird and undesirable. Python >> variables just don’t have a static type, and even if they did, the >> attributes are dynamic rather than determined by the type any

[Python-ideas] Re: Proposal for an additional type system

2020-01-31 Thread Andrew Barnert via Python-ideas
ht be a reasonable proposal, but you’d need to look them all over and make the case for why one design is the right one to standardize on and why it needs to be standardized in the first place, not just suggest that we should have something underspecified. _

[Python-ideas] Re: addition of "nameof" operator

2020-01-31 Thread Andrew Barnert via Python-ideas
Here’s a concrete proposal. tl;dr: `nameof x == "x"`, and `nameof x.y == "y"`. Rationale: Even though as far as Python is concerned `nameof x.y` is identical to `"y"`, it can make a difference to human readers—and to at least two classes of automated tools. W

[Python-ideas] Re: addition of "nameof" operator

2020-01-31 Thread Andrew Barnert via Python-ideas
Sorry, sent early… ignore that and try this version. > > On Jan 31, 2020, at 19:58, Andrew Barnert wrote: > > Here’s a concrete proposal. > tl;dr: `nameof x == "x"`, and `nameof x.y == "y"`. Rationale: Even though as far as Python is concerned `nameof

[Python-ideas] Re: addition of "nameof" operator

2020-01-31 Thread Andrew Barnert via Python-ideas
ight thing >> for the trivial case that, as Greg Ewing says, would already work fine >> without a check anyway. > > Yes, really. It's dynamic, so it must pay attention to the context it's being > used in. Why? The name of a variable does not depend on its runtime con

[Python-ideas] Re: !$? operators for gratuitous overloading

2020-02-02 Thread Andrew Barnert via Python-ideas
as well go full Haskell and allow people to define any string of symbol characters as a new operator. Of course that’s hard to do in Python, both because of the question of where to define things early enough and globally enough, and because Python doesn’t require spaces around operators so ther

[Python-ideas] Re: addition of "nameof" operator

2020-02-02 Thread Andrew Barnert via Python-ideas
> On Feb 2, 2020, at 09:14, Johan Vergeer wrote: > > Thank you so much for this concrete proposal. I could not have described it > clearer myself. > > I'm not sure about leaving out the parentheses. But this is mostly out of > preference. Especially since Python al

[Python-ideas] Re: addition of "nameof" operator

2020-02-03 Thread Andrew Barnert via Python-ideas
strings compared to those outside. >> >> Ignoring the red herrings, I see no utility in a nameof operator and no way >> for it to actually do anything useful. >> >> --- Bruce > > IF Python had a proper refactoring tool (see my other message where I > quest

[Python-ideas] Re: addition of "nameof" operator

2020-02-03 Thread Andrew Barnert via Python-ideas
On Feb 3, 2020, at 10:25, Andrew Barnert wrote: > > This is the same as Smalltalk, ObjC, Ruby, f-script, and all of the other > languages that use the same dynamic type/data model as Python. And Smalltalk > was the first language to have practical refactoring tools (although I do

[Python-ideas] Re: !$? operators for gratuitous overloading

2020-02-03 Thread Andrew Barnert via Python-ideas
perators by using single characters for each? And so on. And operator strings don’t work in Python, where things like 2+-3 are perfectly valid sequences of two operators (and 2-=3 is valid and not even an operator). Also, without sectioning, it would be hard to refer to operators—Python has the

[Python-ideas] Re: Perhaps allow leading zeroes in integer literals

2020-02-06 Thread Andrew Barnert via Python-ideas
On Feb 6, 2020, at 04:06, Jonathan Fine wrote: > > A NEWBY GOTCHA > > > A standard way of writing today's date is 2020-02-06. Let's try this in > Python, first with Christmas Day, and then for today: > > >>> datetime.date

[Python-ideas] Re: `raise as` to raise with current exception as cause

2020-02-07 Thread Andrew Barnert via Python-ideas
hink using the default unless there's a > reason not to is, in general, a good policy. And everyone else commenting on the thread seems to be agreeing with Carlton. So it sounds like they’re probably not going to use the new syntax even if you get this feature into Python. And that rais

[Python-ideas] Re: `raise as` to raise with current exception as cause

2020-02-07 Thread Andrew Barnert via Python-ideas
problems I’m not seeing here. But it seems at least worth exploring. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.

[Python-ideas] Re: pickle.reduce and deconstruct

2020-02-07 Thread Andrew Barnert via Python-ideas
> really slow. (And, that was kind of the point, to do something interesting > using esoteric, inappropriate corners of python.) > > If Andrew's proposal happened, pickle would be uncoupled from that core > machinery, and my idea, as well as other interesting ideas, could b

[Python-ideas] Re: Pickle to/from filename or path

2020-02-07 Thread Andrew Barnert via Python-ideas
dules. So, I don’t think you’d want to change pickle to be different from everything else, but it might be a major process to get everything changed. Also, while there is code in Python that does this “file object or path” thing, I think it’s mostly older code, and not something to encourage going

[Python-ideas] Re: `raise as` to raise with current exception as cause

2020-02-07 Thread Andrew Barnert via Python-ideas
of the borderline where three vs. seven characters would push it over the edge for any given developer? Maybe, but I doubt enough such cases to change things. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email t

[Python-ideas] Re: `raise as` to raise with current exception as cause

2020-02-07 Thread Andrew Barnert via Python-ideas
ut if it is, I think Shai’s idea (or mine, if I misinterpreted Shai’s) might be a decent match, and very simple. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mai

[Python-ideas] Re: statement-scoped context managers (was: Re: Pickle to/from filename or path)

2020-02-08 Thread Andrew Barnert via Python-ideas
o stop thinking of it as a syntactic transformation and instead think of the semantics directly: the with affects the innermost scope if it’s smaller than the innermost statement, even though there’s no way to rewrite it like that. But then nothing else in Python is defined as a syntactic rew

[Python-ideas] Re: Multi-threading interface idea

2020-02-08 Thread Andrew Barnert via Python-ideas
arn even the basic use of futures and executors, of course that's fine. And if you put it on PyPI, maybe others will find it useful as well. But I don't think there's any need for it in the stdlib or anything. ___ Python-ideas ma

[Python-ideas] Re: Function call in (kw)args

2020-02-09 Thread Andrew Barnert via Python-ideas
braries that do it for me, either. You only need to create one decorator that creates wrapping functions. There is a library that deals with args and kwargs for you, and it comes with Python: inspect. There are also libraries in PyPI to help write decorators, to do cast-like stuff, etc. If there

[Python-ideas] Re: Function call in (kw)args

2020-02-09 Thread Andrew Barnert via Python-ideas
rapper @implicit_cast def f(x: int, y=2, *, z) -> int: return x+y+z_______ 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

[Python-ideas] Re: Function call in (kw)args

2020-02-09 Thread Andrew Barnert via Python-ideas
ink you’re just being misled by the fact that the implementation has to deal with a few of the same issues; to the user, method lookup and constructor calls look and act nothing alike, in both languages. > The traits thing is just as much of an implicit cast as Python methods are an > implicit c

[Python-ideas] Re: New syntax for decorators that are compatible with both normal and async functions

2020-02-09 Thread Andrew Barnert via Python-ideas
lve `async? def` into `async def` or `def` at compile time, because which one you want depends on the runtime value of `func`. And, even if that weren’t a problem, how is Python supposed to know what to look at to decide whether it’s async or not? The type of the value passed for the first paramet

[Python-ideas] Re: pickle.reduce and deconstruct

2020-02-09 Thread Andrew Barnert via Python-ideas
mo, rv, recurse=recurse) y = transformer(y) # bottom-up walk # If is its own copy, don't memoize. if y is not x: memo[d] = y memo.setdefault(id(memo), []).append(x) # make sure x lives at least as long as d return y I think this is sufficiently n

[Python-ideas] Re: New syntax for decorators that are compatible with both normal and async functions

2020-02-10 Thread Andrew Barnert via Python-ideas
best model for new code doesn’t mean it’s the always best model for porting all code. ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python

[Python-ideas] Re: Improving Traceback for Certain Errors by Expanding Source Displayed

2020-02-10 Thread Andrew Barnert via Python-ideas
cks to do that plus adding all kinds of useful heuristics might be nifty.) _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.pytho

[Python-ideas] Re: PEP 614: Relaxing Grammar Restrictions On Decorators

2020-02-11 Thread Andrew Barnert via Python-ideas
he PEP can dismiss the problem, just not in the way it currently does.___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ M

[Python-ideas] Re: PEP 614: Relaxing Grammar Restrictions On Decorators

2020-02-11 Thread Andrew Barnert via Python-ideas
I figured out how to skip over all the docker-compose helpers…). I don’t know if anyone’s using it in real life code, but it should be fine to use as an example to show that even with such libraries there’s no ambiguity. ___________ Python-ideas mailing list --

[Python-ideas] Re: New syntax for decorators that are compatible with both normal and async functions

2020-02-11 Thread Andrew Barnert via Python-ideas
just unnecessary static typing, but a good use of it. If there is a problem with asyncio (and similar libraries, both in Python and elsewhere), it’s that it forces you to rethink more than just where you can block. For example, you can’t just turn a csock.recv(BUFSIZE) into an await csock.re

[Python-ideas] Re: CSV Dictwriter - Handling escape characters

2020-02-12 Thread Andrew Barnert via Python-ideas
In your comments, you seem to have a lot of confusion about the difference between Python string literals, JSON string encodings, and the underlying strings, so it’s hard to be sure, but I’m about 90% sure that your actual strings have newlines, not backslash-escaped newlines. But regardless of wh

[Python-ideas] Re: PEP 572: Is it a good ideas that walrus operator can be used in assertions since it causes side effects?

2020-02-12 Thread Andrew Barnert via Python-ideas
possibly be getting 0 out of that calculation before realizing you’re actually getting None? ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/pytho

[Python-ideas] Re: Global thread executor

2020-02-15 Thread Andrew Barnert via Python-ideas
fig or the run loop, or whatever. Presumably the goal here is that having it come with Python would mean lots of third-party libraries would start using it. Similar to GCD (Grand Central Dispatch): its default dispatch queues would only be a minor convenience that you could trivially build yoursel

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-15 Thread Andrew Barnert via Python-ideas
threading > or process execution. To address this I use a utility called a > `SerialExecutor` which shares an API with > ThreadPoolExecutor/ProcessPoolExecutor but executes processes sequentially in > the same python thread: This makes sense. I think most futures-and-executors fra

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-15 Thread Andrew Barnert via Python-ideas
onathan’s sense here. [4] Checking the docs, it looks like the immediate policy didn’t make into C++11 either. But anyway, the deferred policy did, and that’s serial in Jonathan’s sense.___ Python-ideas mailing list -- [email protected] To u

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Andrew Barnert via Python-ideas
ot just that `0b101` and `5` are the exact same number, 5, it’s also that all of your operations already make sense for that number 5, and almost all of them are already implemented as operators or methods in Python. So the main part of your question doesn’t even make sense. But there is an additi

[Python-ideas] Re: Exception-aware operators

2020-02-17 Thread Andrew Barnert via Python-ideas
e couldn’t make None-aware operators feel right as part of Python—but exception-aware operators have the same risk. (And there’s no obvious way to do both that feels consistent.) > however, exception-aware operators could be a potential alternative that: > > 1. works with existing cod

[Python-ideas] Re: Add Binary module.

2020-02-17 Thread Andrew Barnert via Python-ideas
d be in the stdlib. And, if it gets rejected, you still have it for your own use, and can publish it on PyPI for others. (And maybe, if it gets a lot more use than other people expected, you can propose it to be added to the stdlib again in the future. _______

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-17 Thread Andrew Barnert via Python-ideas
ackground thread. That’s the naming used in the third-party C++ and ObjC libs I’ve used most recently, and it may be more common than that—but it may not, in which case my reading may be idiosyncratic and not worth worrying about. ___ Python-ideas

[Python-ideas] Re: Add a __valid_getitem_requests__ protocol

2020-02-18 Thread Andrew Barnert via Python-ideas
ve use as a word qualifies as “excessive swearing” per the CoC, surely an -ideas thread isn’t the place to have it? ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.pyt

[Python-ideas] Re: Specify number of items to allocate for array.array() constructor

2020-02-21 Thread Andrew Barnert via Python-ideas
27;s wrong with `array.array("i", [0])*64` or equivalent? > > On my machine, at least, constructing a bytes object first followed by > an array is significantly faster than the alternative: > > [steve@ando cpython]$ ./python -m timeit -s "from array import array"

[Python-ideas] Re: SQL string prefix idea

2020-02-21 Thread Andrew Barnert via Python-ideas
On Feb 21, 2020, at 05:54, [email protected] wrote: > > lUnfortunately when I try to type s"select * from table" it gave me syntax > error instead, so I think this need to be implemented in Python language > itself instead of module Well, it can be implemented

[Python-ideas] Re: Proposal: Complex comprehensions containing statements

2020-02-21 Thread Andrew Barnert via Python-ideas
om inside a comprehension do? _______ 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.p

[Python-ideas] Re: Proposal: Complex comprehensions containing statements

2020-02-21 Thread Andrew Barnert via Python-ideas
> On Feb 21, 2020, at 15:34, Greg Ewing wrote: > > On 22/02/20 11:45 am, Andrew Barnert via Python-ideas wrote: >> there’s no reason you can’t write `[(yield None) for _ in range(3)]` to >> gather the first three values sent into your generator > > Currently thi

[Python-ideas] Re: SQL string prefix idea

2020-02-21 Thread Andrew Barnert via Python-ideas
whatever and you’re 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/ Message archived at https://mail.python.org/arch

[Python-ideas] Re: Meta: ideas for Python [-ideas]

2020-02-23 Thread Andrew Barnert via Python-ideas
ant to illustrate what can be done. It > also includes a slightly less minimal and hopefully less clumsy way of > filtering the token stream. A reasonably complete documentation is available > [3]. This is very cool. It’s something I keep wanting to do but never get around to it. I even

[Python-ideas] Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
Currently, Python only has ~ (tilde) in the context of a unary operation (like `-`, with __neg__(self), and `+`, __pos__(self)).  `~` currently calls `__invert__(self)` in the unary context. I think it would be awesome to have in the language, as it would allow modelling along the lines of R

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-23 Thread Andrew Barnert via Python-ideas
ther methods that return indices, etc.—except that it isn’t Iterable doesn’t feel like Python. Python even lets you iterate over even “old-style semi-sequences”, things which define __getitem__ to work with a contiguous sequence starting from 0 until they raise IndexError. I think if you want to

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
ce, `a ~= b` but I don't currently have a strong motivating use-case for 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 a

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
what we're currently doing in statsmodels right now because we lack the binary (in the sense of two-arguments) `~`. See: https://www.statsmodels.org/dev/example_formulas.html _______ Python-ideas mailing list -- [email protected] To unsubscrib

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
at PEP 465. Should I write up a PEP? ___ 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

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
.). Sympy is rather new, but I think they'd appreciate it since they have an entire subpackage for distributions: https://docs.sympy.org/latest/modules/stats.html I do envision other usages, but these are the strongest cases I have right now. ___ Python-i

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
dless. ___ 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/python-

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
My main goal here is to increase the flexibility of Python for various domains where I have used `object0 ~ object1` - and can't yet do so in Python. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ide

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Aaron Hall via Python-ideas
bolically by `model`. Such a model consists of a series of terms separated by `+` operators." - https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/formula My main goal, here, again, is to open up the language to make, what I have en

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Aaron Hall via Python-ideas
precedence correct? In R (and Patsy) the binding is the weakest. In Python, my first inclination is to make it the strongest so we could coalesce with the `y` object the other variables. But maybe this is wrong. Maybe it should be a weak binding. Maybe we can't make it weak because some peo

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Aaron Hall via Python-ideas
Thank you all for your discussion! Cheers! ACH ___ 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: Means of comparing slices for intersection or containment containment and computing intersections or unions

2020-02-29 Thread Andrew Barnert via Python-ideas
On Feb 29, 2020, at 10:03, Steve Jorgensen wrote: > > > In that case, I still do think that this kind of functionality is of enough > general use to have something for it in the Python standard library, though > it should probably be through the introduction of a new type

[Python-ideas] Re: More descriptive error message than "too many values to unpack"

2020-03-01 Thread Andrew Barnert via Python-ideas
a non-builtin type. How often do you accidentally unpack a length-6 dict where you wanted to unpack a length-2 dict? _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://m

[Python-ideas] Re: None should raise a new exception, NoneError

2020-03-02 Thread Andrew Barnert via Python-ideas
On Mar 2, 2020, at 08:40, Soni L. wrote: > > All operations on None should raise a NoneError, So every function in every type implemented in C or in Python, whether part of Python or third-party, that has code like this: if not isisntance(arg, numbers.Integral): raise TypeE

[Python-ideas] Re: None should raise a new exception, NoneError

2020-03-02 Thread Andrew Barnert via Python-ideas
On Mar 2, 2020, at 09:26, Soni L. wrote: > >> On 2020-03-02 2:04 p.m., Andrew Barnert wrote: >> On Mar 2, 2020, at 08:40, Soni L. wrote: >> > > All operations on None should raise a NoneError, >> >> So every function in every type implemented in C or i

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-03-02 Thread Andrew Barnert via Python-ideas
hat a chr can not represent an extended grapheme cluster; that would have to be represented as a str, or as some new type that’s also a Sequence[chr]. But since Python strings don’t act like sequences of EGCs today, that’s not a new problem. It could be used to hold code points (so bytes could

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-03-03 Thread Andrew Barnert via Python-ideas
le who usually work in Java or whatever but occasionally have to do Python. Of course regular Python developers have this drummed into their heads, and usually remember to check for str and handle it specially, and we’ve all learned to deal with the tuple-special idiom, and so on. But that doesn

[Python-ideas] Re: Exception for parameter errors

2020-03-04 Thread Andrew Barnert via Python-ideas
n the caller side (the ceval bytecode handler and the PyCall functions). But if you put it on the callee side, how do you handle everything? Presumably you want to handle C functions as well as Python functions; can you change the PyArg parsing functions? (I assume argclinic uses those?) That stil

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-04 Thread Andrew Barnert via Python-ideas
dered) or np.array (where they aren’t even Boolean-values)? In particular, transitivity keeps coming up, but all of those examples are transitive (it’s never true that ahttps://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archive

[Python-ideas] Re: Exception for parameter errors

2020-03-04 Thread Andrew Barnert via Python-ideas
hat can cover all of the common cases). If people are switching on the error message string in real code (and I think I’ve done that once, for Python 2.7/3.3 code where I auto-generated wrappers around appscript proxies), there ought to be another way, and having a new error subclass is the obvi

<    5   6   7   8   9   10   11   12   13   14   >