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
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
> 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
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 --
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
> 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
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://
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
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
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
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
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
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
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
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
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
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.
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
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’
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
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?
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
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
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
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
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
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
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
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
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
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'
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
: {
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
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
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"
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
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.
_
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
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
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
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
> 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
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
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
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
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
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
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.
> 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 --
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
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
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
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
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
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
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
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
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.
_______
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
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
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"
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
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
> 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
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
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
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
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
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
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
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
.).
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
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-
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
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
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
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
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
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
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
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
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
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
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
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
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
901 - 1000 of 1690 matches
Mail list logo