[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-06 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-06 Thread Martin Euredjian via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-07 Thread Martin Euredjian via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-07 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-07 Thread Andrew Barnert via Python-ideas
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. _____

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Andrew Barnert via Python-ideas
> _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

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: A bit change to create a matrix variable in Python as easy as MATLAB and Julia!

2019-11-08 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-10 Thread Andrew Barnert via Python-ideas
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".

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-10 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-10 Thread Martin Euredjian via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-10 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: A bit change to create a matrix variable in Python as easy as MATLAB and Julia!

2019-11-11 Thread Andrew Barnert via Python-ideas
… 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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-11 Thread Martin Euredjian via Python-ideas
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

[Python-ideas] Re: Domain Specification

2019-11-11 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: `__lcontains__` for letting the other class determine container membership when `__contains__` fails

2019-11-12 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-13 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
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. >>

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
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. _______

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-14 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-15 Thread Andrew Barnert via Python-ideas
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. _____

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-15 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Use __signature__ in help() and perhaps somewhere else too

2019-11-15 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-16 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Tuple Comprehension

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Differentiate variables form everything else

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[email protected]

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Differentiate variables form everything else

2019-11-18 Thread Andrew Barnert via Python-ideas
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,

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Differentiate variables form everything else

2019-11-18 Thread Andrew Barnert via Python-ideas
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.

[Python-ideas] Re: Tuple Comprehension

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Differentiate variables form everything else

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-18 Thread Andrew Barnert via Python-ideas
, 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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-18 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Improved Function Decorators

2019-11-18 Thread Andrew Barnert via Python-ideas
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.) _

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Ability to set precedence of classdict (returned from __prepare__) for a metaclass type

2019-11-19 Thread Rob Cliffe via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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__,

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-22 Thread Rob Cliffe via Python-ideas
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

[Python-ideas] Re: Python should take a lesson from APL: Walrus operator not needed

2019-11-22 Thread Rob Cliffe via Python-ideas
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

[Python-ideas] Re: Percent notation for array and string literals, similar to Perl, Ruby

2019-11-24 Thread Rob Cliffe via Python-ideas
. +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

[Python-ideas] Re: Update pep8 for stressing type hinted long parameter in functions

2019-11-27 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Calendar.year()

2019-11-27 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-27 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-28 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-29 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-30 Thread Andrew Barnert via Python-ideas
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: >>

[Python-ideas] Re: namedtuple for dict.items()/collections.abc.Mappings.items()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: namedtuple for dict.items()/collections.abc.Mappings.items()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Renaming json.load()

2019-11-30 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: namedtuple for dict.items()/collections.abc.Mappings.items()

2019-11-30 Thread Andrew Barnert via Python-ideas
# 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

[Python-ideas] Re: Suggestion for language addition

2019-12-02 Thread Andrew Barnert via Python-ideas
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://

[Python-ideas] Re: Suggestion for language addition

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Sets for easy interning(?)

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Sets for easy interning(?)

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Sets for easy interning(?)

2019-12-03 Thread Andrew Barnert via Python-ideas
> 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

[Python-ideas] Re: Fwd: re.findfirst()

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Archiving Threads / Closing Threads

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Sets for easy interning(?)

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Fwd: re.findfirst()

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggestion for language addition

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggestion for language addition

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Archiving Threads / Closing Threads

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Sets for easy interning(?)

2019-12-03 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: math.copysign not to introduce float

2019-12-04 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Allow user extensions to operators [related to: Moving PEP 584 forward (dict + and += operators)]

2019-12-04 Thread Andrew Barnert via Python-ideas
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]

[Python-ideas] Re: Suggestion for language addition

2019-12-04 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggestion for language addition

2019-12-04 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Suggestion for language addition

2019-12-04 Thread Andrew Barnert via Python-ideas
’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

[Python-ideas] Re: Suggestion for language addition

2019-12-04 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Fwd: Re: Fwd: re.findfirst()

2019-12-05 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Fwd: Re: Fwd: re.findfirst()

2019-12-05 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-05 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Fwd: Re: Fwd: re.findfirst()

2019-12-06 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-06 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Fwd: Re: Fwd: re.findfirst()

2019-12-07 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-07 Thread Andrew Barnert via Python-ideas
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/

[Python-ideas] Re: Argumenting in favor of first()

2019-12-07 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-08 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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]

[Python-ideas] Re: Fwd: Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Andrew Barnert via Python-ideas
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

[Python-ideas] Re: Argumenting in favor of first()

2019-12-10 Thread Andrew Barnert via Python-ideas
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

<    3   4   5   6   7   8   9   10   11   12   >