On Nov 7, 2019, at 01:04, Martin Euredjian via Python-ideas
wrote:
>
> >> No professional thinks that "a = some_object" results in a bucket being
> >> filled with whatever the object might contain.
> > That's exactly how variables work in many c
ng makes sense, yet it doesn't take very long for someone
to recognize the characters, attach them to sounds and then make words, badly
at first and better with time.
Note that I am not proposing a complete APL-ization of Python. My only
observation was that the judicious introduction of a sing
zing if we could move away from text-only programming
and integrate a rich environment where such documentation could exist and move
with the code.
Anyhow, not suggesting, by any stretch of the imagination, that these things
are a necessity for Python. You asked an important and interesting que
fully designed by half the core APL team. If he hates
that, I’m pretty sure he wouldn’t be happy with Sinclair APL.
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.py
act that you can touch type them into Mail.app and pine
and a StackOverflow answer box and a blog comment and a general purpose text
editor and get the exact same result you get in PyCharm or PyDev. That’s a
pretty huge difference, which the OP is ignoring.
_____
e import system in general? If not, do we have to deprecate
importing bare struct?
What exactly is in std? Everything installed with the system? Everything that
happens to be in a particular directory (plus statically linked in plus frozen
into the bootstrap)? Just the stuff that’s available
On Nov 8, 2019, at 18:14, Brian Skinn wrote:
>
> For nonbuiltins, the full path to the relevant .py is returned:
>
>> inspect.getfile(inspect)
> 'C:\\...\\Python\\Python37\\Lib\\inspect.py'
What does it do for zipimported modules, bootstrapped modules, modules
> _constraining_ imports only to certain of those category/ies; it "... would
> be a piece of a nightmare"
I’m not sure it would be that hard.
The standard install directories have to get set up at Python install time, and
the installer knows which of those directories are
with the same name as a stdlib module _deliberately_. And we want to be
careful not to gratuitously break any legit uses of that.
Usually, packages that exist in Python 3.x but are on PyPI for 3.(x-1) and
earlier have different names (statistics vs. stats, enum34 vs. enum, etc.), so
the user code h
On Nov 8, 2019, at 04:19, [email protected] wrote:
>
> (2) Using semicolons as a flag to make a better integration of a List-like
> data type and Numpy. The Python interpreter will check whether the numpy
> library is installed. If not, it will stop running and remind the user to
On Nov 10, 2019, at 08:00, Stephen J. Turnbull
wrote:
>
> Andrew Barnert via Python-ideas writes:
>>> On Nov 7, 2019, at 19:59, Chris Angelico wrote:
>>>
>>> And I do the same with the operators that you disparagingly call
>>> "ASCII soup".
On Nov 10, 2019, at 08:23, Stephen J. Turnbull
wrote:
>
> Martin Euredjian via Python-ideas writes:
>
>> Another interesting example is had in some of my work with real
>> time embedded systems. There are plenty of cases where you are
>> doing things that are v
e case that someone is actually
going to get out of that box and comprehend what you are saying.
BTW, there are some interesting efforts out there, like this:
https://www.youtube.com/watch?v=1iTPLgfmFdI
Once you dig into these truly interesting examples you end-up discovering that
notat
On Nov 10, 2019, at 20:50, Martin Euredjian via Python-ideas
wrote:
>
> > This has nothing to do with representation or input via text
>
> It does, it's an extension of the reality that, after so many decades, we are
> still typing words on a text editor.
And how
… to specify the dtype as a suffix.
And if you want to reuse most of your code in Jython with a Java array library
instead of NumPy, it could install the same affix as NumPy. And if NumPy one
day goes the way of Numeric, merging with another library into something even
better, Python wouldn’t be
tion of a single symbol rather than piling on stuff. I love Python
and will continue to use it, including the walrus operator. Life goes on.
Admin: If you have a way to just delete this entire thread, please do so. It
was a waste of time for all involved.
Th
On Nov 11, 2019, at 15:58, Chris Angelico wrote:
>
> I'd recommend exploring two paths:
>
> 1) MacroPy
> 2) Preprocessors/compilers
>
> MacroPy is an insanely powerful tool for messing around with Python.
> You may well be able to do what you want that way. If
this. If your tree is defined as substrings
of a string, why isn’t your root the maximal string, instead of an empty
string? Also, why does `node in “yellow”` work in the first place, when
“yellow” is a str, not a Node? Also, any string is a substring of itself; do
you actually want every
out
at that point.
But this all based on my memory, which is probably wrong or fuzzy on at least
some points, so you really should dig up all of the old threads.
___________
Python-ideas mailing list -- [email protected]
To unsubscribe send an
keyword and end with a colon? There's no syntactic ambiguity there,
>>> right? Honestly, adding this would make me less annoyed with the error I
>>> get when I forget the colon, since it'd actually have a purpose other than
>>> grit on the screen.
>>
On Nov 14, 2019, at 09:53, Andrew Barnert via Python-ideas
wrote:
>
> Yeah, it seems like this should be doable in basically the same way bracketed
> multiline expressions are. I’m not sure how much of a change that would
> require. But it seems like it’s worth fiddling with
enize.py have enough info to handle that
properly? I don’t know, and the answer to that might be a good proxy to the
question of whether it can be done in the real compiler without making parsing
complicated, even if it won’t prove the answer either way.
_______
seemed potentially more
promising than the original (and frequent) suggestion to add parens here.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.pytho
On Nov 14, 2019, at 13:23, MRAB wrote:
>
>> On 2019-11-14 19:51, Andrew Barnert via Python-ideas wrote:
>> On Nov 14, 2019, at 11:21, Random832 wrote:
>>>> On Thu, Nov 14, 2019, at 13:12, Andrew Barnert wrote:
>>>> And then you can run it on a whole
r cases. But it seems like
it’s at least worth building for your personal toolbox and keeping track of how
often it comes up (and how much nicer it makes things), and maybe publishing it
to PyPI or submitting it to contextlib2 so more people will do the same.
_____
osest thing they have
to a not-opened-file type is a fancy URL type (which, in Swift, can be pretty
fancy—it can be a file: URL with an embedded access token that you got from
opening a security scoped bookmark, for example).
Also, I think it would get in the way of some handy shortcuts that Py
gnature__ that way? What’s wrong with
treating it the same as the other mutable attributes and just assigning it
normally (or with a decorator)?
> Externally, this would behave like a function with the given (more restrict)
> signature (e.g. raising TypeError if it doesn't match the give
that only cleans up if the generator is cleaned up…)
Or breaking file objects up into as many orthogonal pieces as possible to see
if there’s a better way to reassemble them?
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an
tax? I don’t think so.
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/py
n a variable and anything else?
In Python, functions, classes, modules, etc. are all just values, bound to
names in the same way as any other value. Everything that looks like an
identifier is a variable except for language keywords.
IDEs have no problem coloring the fixed set of keywords diff
enate two strings.
> Tony+Maria
> is what we used to write when we were little children fallen in love, but
> once we grow up, we started to think (more or less) and write the following:
> Tony & Maria
Your argument is that + is simple enough that it’s the first thing little
child
e cases you close the file at the end of the function, but for other cases
you pass the file off to a daemon thread that will close the file when it
finishes (or just leak the file and let the OS handle it if it doesn’t finish).
That seems like a case for ExitStack rather than for using a file as a
On Nov 18, 2019, at 10:27, Random832 wrote:
>
> On Mon, Nov 18, 2019, at 13:00, Andrew Barnert via Python-ideas wrote:
>>def f(a, b): return a**(b+1)
>>g = partial(f, b==2)
>>h = lambda x: f(x, 2)
>>
>> Python can’t tell the difference between f,
g the closing cm on it in a different lexical context that
you end up passing the released cm to).
(I think C++ smart pointers might be relevant here, or maybe something from
Rust, although I haven’t thought it through in much detail.)
___
Python-ideas mailing list -- pyth
ts__, or even replace their
__code__.
In fact, there aren’t very many _immutable_ callables (by comparison to the
huge number of functions).
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to python-ideas-le...@python.
to a tuple.
At the C API level, tuples are mutable, and this is safe to use as long as
you’re sure no Python code has a reference to the tuple. So there’s no reason
we couldn’t have a special TUPLE_APPEND op that’s only used in tuple
comprehensions, the same way LIST_APPEND is used in list c
atever in the first place?
_______
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
, but something explicit), would that make your code substantially
worse?
If there were two builtins to open a file, one that gave you a cm and one that
didn’t, would that raise the burden of learning and remembering Python too
high? What if the second one wasn’t a builtin but had to be imported from i
On Nov 18, 2019, at 16:35, Soni L. wrote:
>
>
>> On 2019-11-18 5:22 p.m., Soni L. wrote:
>>
>>
>>> On 2019-11-18 5:13 p.m., Andrew Barnert via Python-ideas wrote:
>>>> On Nov 18, 2019, at 10:51, Random832 wrote:
>>> > > On Mo
behaves that way into the stdlib. Or just mention
how to do (and that helpers are readily available) in the docs on decorators.
(I don’t think it means we need to add a whole new decorator syntax that just
does that for you magically but is otherwise the same as the existing one.)
_
f the stdlib and 80% of the third-party ecosystem being inherited without
wrappers from C, and therefore not exception safe…). But that doesn’t mean a
language can’t benefit from the distinction.
For example, notice that Python doesn’t have C++‘s complicated member
destructor rules or ObjC’s d
ile would probably work.
But is that better than an opening function that takes a Path (or any of the
other valid arguments to open) as its first argument?
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to python
er gets called, so fn2 still gets created or truncated, and on top of that
we leak a file handle.
The only way to fix this is to move the open itself into a with statement—just
like in Python 3.8, so we haven’t gained anything.
Moving the actual open to __enter__, on the other hand, does solve t
classdict raises `KeyError`.
Can I make a plea that posters to this (and other) lists do not
introduce acronyms, abbreviations or jargon that are not commonly used
Python terminology and may not be familiar to everyone who reads them?
(I say "_*introduce*_". I have no problem with a term ex
On Nov 19, 2019, at 14:30, Greg Ewing wrote:
>
> On 20/11/19 6:51 am, Andrew Barnert via Python-ideas wrote:
>> A class can bind attributes in __new__ and return a fully initialized
>> object. If that’s perfectly ok, why doesn’t every class do everything
>> in __new__,
gs in Smalltalk and ObjC are
ubiquitous conventions instead of language-supported, and this is one of them.
Calling new followed by init* is just a convention, but it’s a convention
followed almost ubiquitously.
In Python, the 99% case is automated—you have to opt out of it in your __new__
for th
his to contextlib2 (or, if Nick rejects it, create your own PyPI
project instead) and see if people use it. If so, you can propose merging it
all into the stdlib, and maybe even shortcuts like making tuples act like
nested.
In the long run, you can start pressuring people to write their tuto
advantage to it). So there’s no point in eager context
managers—sure, someone could go out of their way to write one, but then you
probably could get away with saying that it’s “broken”, unlike today.
This is still more verbose than current Python, and passing a function and its
args doesn’t look
On 06/11/2019 17:05:21, Martin Euredjian via Python-ideas wrote:
One has to use APL for real work and for at least a year or two in
order for your brain to make the mental switch necessary to understand
it. Just messing with it casually isn't good enough. Lots of
inquisitive people
On 11/11/2019 17:10:40, C. Titus Brown wrote:
Hi folks,
moderator here. I’d (strongly) suggest no further replies, unless there’s
something Python specific to discuss. I’ll put the list into emergency
moderation for a bit.
thanks,
—titus
Agreed.
The OP used APL for a number of years, and
.
+1.
Rob Cliffe
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org
ve
> spaces around the ->arrow if present. (See Function Annotations below for
> more about function annotations.)
The linked section also says:
The Python standard library should be conservative in adopting such
annotations, but their use is allowed for new code and for big refactor
ryear) vs. prmonth?
_______
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/pytho
ing contents.
That’s a lot more confusing. I frequently accidentally try to parse a pathname
as an XML document, or to open a file using an XML document as a pathname, but
I never make that mistake with JSON.
___
Python-ideas mailing list -- python-ideas@p
was added, and currentThread
turned into a compatibility alias, back in 2.6.
So the Very Good Thing isn’t actually as good as you’d hope—people will still
have to learn loads—and the downsides are bigger than they appear at first—it
will be a years-long process to get the entire Python ecosystem c
all the screen
space and storage you could want and instantaneous auto-complete and so on, so
the cost of longer names is a lot lower. And, while Python isn’t quite _that_
old, the balance in Python 0.9 was about fitting in with C in a Unix-ish
system, while now Python is about being good for
while
> augmented assignment turns out to be useful to provide mutating
> operations and signal them to the reader, the increment operation is
> purely syntactic sugar compared to "i += 1" as a statement, but
> insufficiently powerful and orthogonal as an expression to ad
e aliases (because they’re just functions),
but what about bound methods (and classmethods and custom method-y decorators)?
For example, if `mine = MyClass()`, does `mine.process_file.__alias__` also
work? How? Do method objects have a @property for the dunder that delegates to
the underlying `__func__`? If not, I
On Nov 30, 2019, at 10:25, MRAB wrote:
>
> On 2019-11-30 05:28, Andrew Barnert via Python-ideas wrote:
>>> On Nov 29, 2019, at 02:42, Steven D'Aprano wrote:
>>> Programming uses lots of initialisms, abbreviations and hybrid words, such
>>> as:
>>
ue, el.key, el.value,
> etc.
I think dict would want to implement it as a C-level structseq (like stat
results) instead of a Python-level namedtuple for convenience and performance,
but that’s not a big issue.
Anyway, I think this would be a good idea. But I’m not sure it’s feasible
The p
On Nov 30, 2019, at 16:15, Steven D'Aprano wrote:
> On Sat, Nov 30, 2019 at 11:54:35AM -0800, Andrew Barnert via Python-ideas
> wrote:
>
>> To an experienced C programmer, both += and ++ are intuitive. But to a
>> novice who’s never programmed, neither one is int
for value, key in d.items()` it will appear correct but
then do the wrong thing inside the loop. (And if I’m trying to fix your code, I
might not even notice that you got it backward until after a couple hours
banging my head on the debugger.) With a namedtuple, there’s no way to mix up
the n
On Nov 30, 2019, at 20:13, Steven D'Aprano wrote:
>
> On Sat, Nov 30, 2019 at 05:31:01PM -0800, Andrew Barnert wrote:
>>> On Nov 30, 2019, at 16:15, Steven D'Aprano wrote:
>>> On Sat, Nov 30, 2019 at 11:54:35AM -0800, Andrew Barnert via Python-ideas
>&g
# error
> x.two-3 # error
The message you quoted was about how in Python 2 (but not 3) you could
destructure parameters:
sorted({1:300, 2:4}.items(), key=lambda (key, value): value)
The wider discussion is about how if items() were a view of namedtuples instead
of just sequences you
u need a closing brace because the dedent could
be a lie, in Python it syntactically means the very thing you hope it means.)_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://
up to the start. But does a ruler
help any better? And would an “end for”?
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org
ing. But a method s.lookup(key)
that returned the member equal to key or raised KeyError doesn’t seem like it
would confuse anyone.
(Meanwhile, if you need this behavior in Python today, and you can’t accept
linear time, but can accept a significant constant multiplier, you could always
grab the o
constructor returns a zero?)
I’m pretty sure I have run into a handful of more useful uses for this method
over the years, but I can’t remember any. Maybe something to do with Unicode
normalization?
___
Python-ideas mailing list -- python-ideas@p
> On Dec 3, 2019, at 03:41, Steven D'Aprano wrote:
> On Tue, Dec 03, 2019 at 01:54:44AM -0800, Andrew Barnert via Python-ideas
> wrote:
>>>>> On Dec 2, 2019, at 16:27, Soni L. wrote:
>>>> Even use-cases where you have different objects whose dif
ight that there would be similar convenience uses for
findfirst, if not even more of them. And it makes more sense to build that
findfirst around findall or finditer than around search.
But, given how easy it is to build this on finditer, and that it uses a general
pattern that works for every si
s. For example, should dict.__or__ and __ior__
handle all the same values as update, or some more restricted set of types? The
same as set.__or__ and __ior__ vs. union, and list.__add__ and __iadd__ vs
extend, and so on. If they’re all consistent, and there’s no compelling reason
to add an i
can, and already do.
And if someone like Serhiy or even Guido is away for a week, does that mean
every thread started during that week should get resolved without their
frequently crucial input?
_______
Python-ideas mailing list -- [email protected]
To
On Dec 3, 2019, at 15:45, Greg Ewing wrote:
>
> On 4/12/19 7:26 am, Andrew Barnert via Python-ideas wrote:
>> If you’re using interning for functionality, to distinguish two equal
>> strings that came from different inputs or processes, your code is probably
>> brok
xt that raises a
> different exception when the result isn't found.
If you need that, it’s pretty trivial to write yourself.
If you think other people need it and don’t know how to write it, why not
submit it to more-itertools and/or tools? If it gets enough uptake, you can
always su
ven written specifically to be rejected, so
there will be an answer for anyone who wonders “Why doesn’t Python do X?”, or
so the next 42 times the idea comes up someone can just reply “Read PEP 789 and
see if you have anything to add” instead of everyone rehashing the same
arguments.
There is
use cases”,
provide one that isn’t silly instead of one that is.
While you’re at it, you might want to show some other languages. I think part
of the reaction against it comes from the languages people are familiar with.
Python, Swift, Ruby, and most other languages people tout as “readable” just
have
ne even worse, so that’s not a serious proposal, just a blue-sky wish.
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Me
if the type is a 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.python.org/archives/list/python
think about whether start==stop is safe, it will obviously safely give you an
empty range.
(You can extend this to be more flexible (take just stop, or start and stop, or
start and stop and abs(step) arguments) if you need it.)
___
Python-ideas mailing
t test 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]
bout once/year for them? That
sounds about right to me, too.
___
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 arc
ed
like when they last ran into it, and how much their workaround bothered 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/
Me
’s likely that you could find that much.)
___________
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://mai
ising an exception is an obvious alternative but I've learned that
> exceptions are expensive. If that's not the case in Python, I'll have to
> unlearn that :-)
Yes, you have to unlearn it. Exceptions are not that expensive in Python (and
in a lot of other modern languages
r itertools and rejected. I don’t remember why, but
generally there’s resistance to adding anything that you could write yourself
(and are unlikely to get wrong) on top of itertools and builtins, unless it
needs to loop and yield itself (in which case it might need the performance
boost of iterating
st even more, because novices shouldn’t learn that bad idea.
_______
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
genexpr if we had both. But a lot of itertoolsy code is full
of lambdas and partials like this (to call filter and map, use as groupby and
unique keys, etc.), and often the condition is something you’ve already wrapped
up as a function in the first place, so I’m not sure how generally that applies
the request to find the problem. After upgrading Python, the
logs would just say alpha, which wouldn’t help me. I’d have to go change the
code to log %r instead of %s (or, maybe, stop being so hacky and explicitly log
the span and groups, and also log where the failed search started rather than
On Dec 6, 2019, at 16:44, Steven D'Aprano wrote:
>
> We could, I guess, eliminate the difference by adding the ability to
> peek ahead to the next value of an arbitrary iterator without consuming
> that value. This would have to be done by the interpreter, not in Python
next(finditer()).group(1), which return a
tuple vs. just the first one?
___________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.pytho
ot really an argument against making a special case for one that isn’t
made for unique or consume.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/
alue?
>
>
> That's a good point: Exception is a bad sentinel value. Is None a good
> default value? What if the genexpr'd iterable is [None, 2, 3]
That’s a common issue in Python. When you can’t use None as a sentinel because
it could be a valid user input or return value, yo
with
a little edited-in footnote or comment saying “if you’re using the upcoming
3.9, you can use first instead of next and leave out the call to iter”.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to python-ideas-l
other. There's also that pypy has trouble
> optimizing code using itertools heavily, _because_ it's written in C
> instead of Python.
Didn’t PyPy already make the fix years ago of rewriting all of itertools (for
both 2.7 and 3.3 or whenever) as “Python builtins” in the underlying
ed. :-)
It’s not that the existing documentation doesn’t yet describe the new way, it’s
that the existing documentation already describes the existing way and
apparently nobody’s finding it. Which casts doubt on how many people will find
the new way.
> I do have to admit that I'm probably
stinguish is, while not nonexistent, pretty
rare. And cases where you need to distinguish them but don’t care what the
types are otherwise are even less common. So, is that common enough to be worth
adding two more exception types to Python (or just to itertools) that aren’t
used anywhere e
take and then curry that. So you can just follow the convention everywhere
without worrying about whether this is one of the rare cases where the other
way around might actually be useful more often.
_______
Python-ideas mailing list -- [email protected]
that you must use iter() for 2-arg next() to (maybe) work right
> is idiosyncratic.
>
> It takes a "Python historian" to understand why it may be correct to use:
>
> the_first_item_if_ordered = next(iter(container), default='not found')
Why “may be correct”? It
istinct from:
>
>first = next
Because first works with any Iterable; next works only with iterators.
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pyth
understand the subtleties of leaking StopIteration, or whatever).
That’s a pretty different argument. (Not that there can’t be something to both
arguments, of course.)
_______
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to
701 - 800 of 1690 matches
Mail list logo