Re: [Python-ideas] Consider adding clip or clamp function to math

2016-08-12 Thread MRAB
On 2016-08-13 00:48, David Mertz wrote: On Fri, Aug 12, 2016 at 4:25 PM, Victor Stinner > wrote: [snip] Also, what is the calling syntax? Are the arguments strictly positional, or do they have keywords? What are those default values

Re: [Python-ideas] globals should accept parenteses for extending beyond 1 line

2017-01-23 Thread MRAB
On 2017-01-23 20:09, Nick Timkovich wrote: Related and probably more common is the need for the line-continuation operator for long/multiple context managers with "with". I assume that's come up before, but was it also just a low priority rather than any technical reason? It has come up before,

Re: [Python-ideas] String Format Callable Flag (Was: Efficient Debug Logging)

2017-02-17 Thread MRAB
On 2017-02-17 16:37, Mark E. Haase wrote: In the debug logging thread, somebody suggested the "%r" format specifier and a custom __repr__. This is a neat solution because Python logging already includes a "delayed" evaluation of sorts: it formats the logging string *after* it determines that the

Re: [Python-ideas] Efficient debug logging

2017-02-14 Thread MRAB
On 2017-02-14 15:51, Barry Scott wrote: A common pattern I use is to have logging calls for debug and information with my applications. The logging calls can be separately enabled and disabled. For example: debug_log_enabled = False def debugLog( msg ): If debug_log_enabled:

Re: [Python-ideas] real numbers with SI scale factors: next steps

2016-08-31 Thread MRAB
On 2016-08-31 05:08, Ken Kundert wrote: What's the mnemonic here? Why "r" for scale factor? My thinking was that r stands for real like f stands for float. With the base 2 scale factors, b stands for binary. 'b' already means binary: >>> '{:b}'.format(100) '1100100'

Re: [Python-ideas] real numbers with SI scale factors: next steps

2016-08-31 Thread MRAB
On 2016-08-31 17:19, Guido van Rossum wrote: On Wed, Aug 31, 2016 at 5:21 AM, Nick Coghlan wrote: On 31 August 2016 at 17:07, Chris Angelico wrote: On Wed, Aug 31, 2016 at 2:08 PM, Ken Kundert wrote: > What's the mnemonic

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-13 Thread MRAB
On 2016-09-13 16:27, Rob Cliffe wrote: On 13/09/2016 12:37, Nick Coghlan wrote: On 13 September 2016 at 21:15, Rob Cliffe wrote: On 13/09/2016 04:43, Guido van Rossum wrote: Yeah, that's exactly my point. PEP 463 gives you a shorter way to catch an exception, so

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread MRAB
On 2016-09-09 21:01, Arek Bulski wrote: Sometimes I find myself in need of this nice operator that I used back in the days when I was programming in .NET, essentially an expression expr ?? instead should return expr when it `is not None` and `instead` otherwise. A piece of code that I just

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possible problem I can see is that if it's quoted you might think that it's an expression and that you could also write: package = "run-lambda>=0.1.0"

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 19:48, Chris Angelico wrote: On Tue, Sep 20, 2016 at 4:43 AM, MRAB <pyt...@mrabarnett.plus.com> wrote: On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possibl

Re: [Python-ideas] SI scale factors in Python

2016-08-26 Thread MRAB
On 2016-08-26 07:54, Steven D'Aprano wrote: [snip] Specialist applications might be able to take shortcuts in dimensional analysis when "everybody knows" what the suppressed units must be. General purpose programming languages *cannot*. It is better NOT to offer the illusion of dimensional

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-08-26 Thread MRAB
On 2016-08-26 14:34, Chris Angelico wrote: On Fri, Aug 26, 2016 at 10:47 PM, Steven D'Aprano wrote: [snip] Or if that's too heavy (two whole characters, plus the suffix!) perhaps we could have a rule that the suffix must follow the final underscore of the number: 8_M #

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-10-28 Thread MRAB
On 2016-08-26 13:47, Steven D'Aprano wrote: Ken has made what I consider a very reasonable suggestion, to introduce SI prefixes to Python syntax for numbers. For example, typing 1K will be equivalent to 1000. Just for the record, this is what you can now do in C++: User-Defined Literals

Re: [Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

2016-11-14 Thread MRAB
On 2016-11-15 02:59, Matthias welp wrote: [snip] e.g. if you use 'a = a + 1', python under the hood interprets it as 'a = a.__add__(1)', but if you use 'a += 1' it uses 'a.__iadd__(1)'. FTR, 'a += 1' is interpreted as 'a = a.__iadd__(1)'. ___

Re: [Python-ideas] Null coalescing operator

2016-11-02 Thread MRAB
On 2016-11-02 16:17, Nick Coghlan wrote: [snip] Yeah, and so far the protocol based alternative I'm working on hasn't been any less headache-inducing (Mark has been reviewing some early iterations and had to draw a diagram to try to follow the proposed control flow). I think I have a way to

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread MRAB
On 2016-11-03 18:36, Chris Barker wrote: Thanks Steven, this is great! so -- when all this started, I think one of the use cases was to clean up this really common idiom: self.an_arg = the_default if an_arg is None else an_arg so would that be: self.an_arg = the_default ?? an_arg That would

Re: [Python-ideas] Null coalescing operator

2016-10-31 Thread MRAB
On 2016-10-31 17:16, Guido van Rossum wrote: I think we should try to improve our intutition about these operators. Many things that are intuitively clear still require long turgid paragraphs in reference documentation to state the behavior unambiguously -- but that doesn't stop us from

Re: [Python-ideas] Null coalescing operator

2016-11-02 Thread MRAB
On 2016-11-02 21:57, Greg Ewing wrote: MRAB wrote: target = expr1 || expr2 || expr3 target = expr1 && expr2 && expr3 except that only None would be considered falsey? Or would that be confusing? Yes, I think that borrowing an operator from C but giving it subtly dif

Re: [Python-ideas] More user-friendly version for string.translate()

2016-10-26 Thread MRAB
On 2016-10-26 23:17, Chris Barker wrote: I"ve lost track of what (If anything) is actually being proposed here... so I"m going to try a quick summary: 1) an easy way to spell "remove all the characters other than these" I think that's a good idea. What with unicode having an enormous number

Re: [Python-ideas] INSANE FLOAT PERFORMANCE!!!

2016-10-12 Thread MRAB
On 2016-10-12 23:34, Alexander Belopolsky wrote: On Wed, Oct 12, 2016 at 6:14 PM, Elliot Gorokhovsky > wrote: so then Latin1 strings are memcmp-able, and others are not. No. Strings of the same kind are "memcmp-able"

Re: [Python-ideas] (no subject)

2016-11-29 Thread MRAB
On 2016-11-29 19:45, Brendan Barnwell wrote: On 2016-11-29 09:43, Brett Cannon wrote: One way to make this cheap is to have a reasonable default message and use attributes on the exceptions trigger the use of the default message. Nearly a year ago I filed a bunch of issues for ideas on

Re: [Python-ideas] Input characters in strings by decimals (Was: Proposal for default character representation)

2016-12-07 Thread MRAB
On 2016-12-07 23:52, Mikhail V wrote: In past discussion about inputing and printing characters, I was proposing decimal notation instead of hex. Since the discussion was lost in off-topic talks, I'll try to summarise my idea better. I use ASCII only for code input (there are good reasons for

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-05 Thread MRAB
On 2017-03-06 03:09, Chris Angelico wrote: On Mon, Mar 6, 2017 at 2:03 PM, Elliot Gorokhovsky wrote: On Sun, Mar 5, 2017 at 7:50 PM Chris Angelico wrote: I would be rather curious to know how frequently a list consists of "numbers", but a mix

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread MRAB
On 2017-03-02 08:03, Serhiy Storchaka wrote: Function implemented in Python can have optional parameters with default value. It also can accept arbitrary number of positional and keyword arguments if use var-positional or var-keyword parameters (*args and **kwargs). But there is no way to

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread MRAB
On 2017-03-01 21:32, Ethan Furman wrote: On 03/01/2017 11:53 AM, Guido van Rossum wrote: FWIW in typeshed we've started using double leading underscore as a convention for positional-only parameters, e.g. here: https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936 I

Re: [Python-ideas] Idea : for smarter assignment?

2017-07-25 Thread MRAB
On 2017-07-25 18:02, Nick Timkovich wrote: On Fri, Jul 21, 2017 at 12:59 PM, David Mertz > wrote: But you've left out quite a few binding operations. I might forget some, but here are several: Ned Batchelder had a good presentation at PyCon

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-25 Thread MRAB
On 2017-07-25 19:48, Giampaolo Rodola' wrote: On Tue, Jul 25, 2017 at 7:49 PM, MRAB <pyt...@mrabarnett.plus.com <mailto:pyt...@mrabarnett.plus.com>> wrote: On 2017-07-25 02:57, Nick Coghlan wrote: On 25 July 2017 at 02:46, Michel Desmoulin <desmoulinm

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-23 Thread MRAB
On 2017-07-23 17:08, Todd wrote: On Jul 20, 2017 1:13 AM, "David Mertz" > wrote: I'm concerned in the proposal about losing access to type information (i.e. name) in this proposal. For example, I might write some code like this now:

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-19 Thread MRAB
On 2017-07-20 02:08, Guido van Rossum wrote: The proposal in your email seems incomplete -- there's two paragraphs on the actual proposal, and the entire rest of your email is motivation. That may be appropriate for a PEP, but while you're working on a proposal it's probably better to focus on

Re: [Python-ideas] Arguments to exceptions

2017-07-03 Thread MRAB
On 2017-07-03 22:44, Paul Moore wrote: On 3 July 2017 at 21:56, Jeff Walker wrote: Paul, Indeed, nothing gets better until people change the way they do their exceptions. Ken's suggested enhancement to BaseException does not directly solve the problem, but it

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread MRAB
On 2017-04-26 18:46, Mike Miller wrote: On 2017-04-26 04:12, Brice PARENT wrote: Why not simply do this : class MyClass: def _set_multiple(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) def __init__(self, a, b, c):

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread MRAB
On 2017-04-26 23:29, Erik wrote: On 26/04/17 19:15, Mike Miller wrote: As the new syntax ideas piggyback on existing syntax, it doesn't feel like that its a complete impossibility to have this solved. Could be another "fixed papercut" to drive Py3 adoption. Taken individually not a big deal

Re: [Python-ideas] How do you think about these language extensions?

2017-08-18 Thread MRAB
On 2017-08-18 13:06, Steven D'Aprano wrote: Hello Thautwarm, and welcome! [snip] # pattern matching use "condic" as keyword is for avoiding the # conflictions against the standard libraries and packages from third # party. "switch" and "match" both lead to conflictions. This is a hard

Re: [Python-ideas] Improving Catching Exceptions

2017-06-22 Thread MRAB
On 2017-06-23 00:29, Cameron Simpson wrote: On 23Jun2017 06:55, Steven D'Aprano wrote: On Thu, Jun 22, 2017 at 10:30:57PM +0200, Sven R. Kunze wrote: We usually teach our newbies to catch exceptions as narrowly as possible, i.e. MyModel.DoesNotExist instead of a plain

Re: [Python-ideas] Reducing collisions in small dicts/sets

2017-06-26 Thread MRAB
On 2017-06-26 19:21, Tim Peters wrote: Some explanations and cautions. An advantage of sticking with pure Python instead of C is that spare moments are devoted to investigating the problem instead of thrashing with micro-optimizations ;-) Why does the current scheme suffer for small tables?

Re: [Python-ideas] π = math.pi

2017-06-03 Thread MRAB
On 2017-06-03 19:50, Thomas Jollans wrote: On 03/06/17 18:48, Steven D'Aprano wrote: On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote: But Python 3.5 does treat it as an identifier! py> ℘ = 1 # should be a SyntaxError ? py> ℘ 1 There's a bug here, somewhere, I'm just not

Re: [Python-ideas] Dictionary destructing and unpacking.

2017-06-08 Thread MRAB
On 2017-06-08 20:16, Nick Badger wrote: Well, it's not deliberately not destructive, but I'd be more in favor of dict unpacking-assignment if it were spelled more like this: >>> foo = {'a': 1, 'b': 2, 'c': 3, 'd': 4} >>> {'a': bar, 'b': baz, **rest} = foo >>> bar 1 >>>

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread MRAB
On 2017-06-18 22:38, Alireza Rafiei wrote: Hi all, I'm not sure whether this idea has been discussed before or not, so I apologize in advanced if that's the case. Consider the behavior: >>> f = lambda: True >>> f.__name__ '' >>> x = f >>> x.__name__ '' I'm

Re: [Python-ideas] Make map() better

2017-09-14 Thread MRAB
On 2017-09-14 03:55, Steven D'Aprano wrote: On Wed, Sep 13, 2017 at 11:05:26PM +0200, Jason H wrote: > And look, map() even works with all of them, without inheritance, > registration, and whatnot. It's so easy! Define easy. Opposite of hard or difficult. You want to map a function?

Re: [Python-ideas] Why not picoseconds?

2017-10-15 Thread MRAB
On 2017-10-15 19:02, Koos Zevenhoven wrote: On Sun, Oct 15, 2017 at 8:17 PM, Antoine Pitrou >wrote: Since new APIs are expensive and we'd like to be future-proof, why not move to picoseconds?  That would be safe until clocks reach the

Re: [Python-ideas] Why not picoseconds?

2017-10-16 Thread MRAB
On 2017-10-16 13:30, Greg Ewing wrote: Stephan Houben wrote: Interestingly, that 2.2e-16 pretty much aligns with the accuracy of the cesium atomic clocks which are currently used to *define* the second. So we move to this new API, we should provide our own definition of the second, since those

Re: [Python-ideas] Membership of infinite iterators

2017-10-18 Thread MRAB
On 2017-10-18 15:48, Nick Coghlan wrote: On 18 October 2017 at 22:36, Koos Zevenhoven > wrote: On Wed, Oct 18, 2017 at 2:08 PM, Nick Coghlan > wrote: That one can only be fixed in

Re: [Python-ideas] Allow additional separator character in variables

2017-11-23 Thread MRAB
On 2017-11-24 00:49, Steven D'Aprano wrote: On Thu, Nov 23, 2017 at 02:24:16PM +0900, Stephen J. Turnbull wrote: Alex Martelli wrote a couple of interesting posts about his experiences with multilingual comments back in the discussion of PEP 263. One of them involved a team from Israel, I

Re: [Python-ideas] [Python-Dev] What's the status of PEP 505: None-aware operators?

2017-11-29 Thread MRAB
On 2017-11-29 21:27, Greg Ewing wrote: Nick Coghlan wrote: What about more English-like syntax: X or else Y The problem with constructs like this is that they look like they should mean the same thing as "X or Y". How about: x otherwise y It looks different enough from "or" that

Re: [Python-ideas] Ignorable whitespaces in the re.VERBOSE mode

2017-11-16 Thread MRAB
On 2017-11-16 10:23, Serhiy Storchaka wrote: Currently the re module ignores only 6 ASCII whitespaces in the re.VERBOSE mode: U+0009 CHARACTER TABULATION U+000A LINE FEED U+000B LINE TABULATION U+000C FORM FEED U+000D CARRIAGE RETURN U+0020 SPACE Perl

Re: [Python-ideas] Allow additional separator character in variables

2017-11-19 Thread MRAB
On 2017-11-20 00:20, Chris Angelico wrote: On Mon, Nov 20, 2017 at 11:01 AM, Mikhail V wrote: 1. The future versions of syntax, ideally, must allow ONLY minus U2212 for the minus operator, and allow hyphens 002D in identifiers. Since it is impossible to the current

Re: [Python-ideas] Ignorable whitespaces in the re.VERBOSE mode

2017-11-16 Thread MRAB
On 2017-11-16 21:44, Serhiy Storchaka wrote: 16.11.17 19:38, Guido van Rossum пише: Who would benefit from changing this? Let's not change things just because we can, or because Perl 6 does it. I don't know. I know the disadvantages of making this change, and I ask what is the benefit. If

Re: [Python-ideas] A proliferation of (un-)Pythonically programmatic pragmas

2017-11-13 Thread MRAB
On 2017-11-13 19:10, Barry Warsaw wrote: I love many of the ancillary tools that help improve the quality of my Python code, including flake8, coverage, and mypy. Each of these usually produces some great diagnostics, but none of them are perfect, so they also produce false positives that have

Re: [Python-ideas] Proposal to change Python version release cycle

2017-11-05 Thread MRAB
On 2017-11-05 03:07, Nick Coghlan wrote: On 5 November 2017 at 01:29, Wolfgang wrote: On 04.11.2017 16:01, Nick Coghlan wrote: We're currently more likely to go the other direction, and stick with the 3.x numbering for an extended period (potentially reaching 3.10, 3.11,

Re: [Python-ideas] Provide a way to import module without exec body

2017-12-01 Thread MRAB
On 2017-12-01 22:46, Steven D'Aprano wrote: On Fri, Dec 01, 2017 at 10:23:37AM -0500, brent bejot wrote: I have found myself implementing something like this before. I was working on a command-line tool with nested sub-commands. Each sub-command would import a script and execute something

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-31 Thread MRAB
On 2017-10-31 18:44, Guido van Rossum wrote: On Tue, Oct 31, 2017 at 11:41 AM, MRAB <pyt...@mrabarnett.plus.com <mailto:pyt...@mrabarnett.plus.com>> wrote: regex gets updated when the Unicode Consortium releases an update. Is it a feature that that is more frequently than Pyt

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-31 Thread MRAB
On 2017-10-31 11:42, Nick Coghlan wrote: On 31 October 2017 at 02:29, Guido van Rossum > wrote: What's your proposed process to arrive at the list of recommended packages? I'm thinking it makes the most sense to treat inclusion in the

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread MRAB
On 2018-05-12 22:07, Cameron Simpson wrote: On 06May2018 02:00, Nick Coghlan wrote: On 5 May 2018 at 13:36, Tim Peters wrote: If only one trailing "given" clause can be given per `if` test expression, presumably I couldn't do that without trickery.

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-15 Thread MRAB
On 2018-05-15 04:32, Tim Peters wrote: Just noting some real code I typed today where `given` works great if it allows unpacking syntax, and assignment expressions don't: while True: head, matched, s = s.partition(sep) if not matched: break Using `given`:

[Python-ideas] Specifying Python version

2018-05-16 Thread MRAB
Instead of verbatim identifiers, how about a special comment giving the Python version in which the file was written? There could then be a tool similar to 2to3 that converts the file to a more recent version of Python that might have new reserved words. In most cases the new file would

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread MRAB
On 2018-05-24 18:08, George Leslie-Waksman wrote: I have had plenty of instances where destructuring a mapping would have be convenient. Relating to iterable destructuring, I would expect the syntax to be of the form "variable: key". I also think the curly-braces make it harder to visually

Re: [Python-ideas] Make keywords KEYwords only in places they would have syntactical meaning

2018-05-18 Thread MRAB
On 2018-05-18 12:22, Ken Hilton wrote: Hi all, Yes, this is another idea for avoiding breaking existing code when introducing new keywords. I'm not sure if this is too similar to Guido's previous "allow keywords in certain places" idea, but here goes: Only treat keywords as having any

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-17 Thread MRAB
On 2018-05-17 22:38, Rob Cliffe via Python-ideas wrote: On 16/05/2018 10:12, Stephan Houben wrote: Hi all, One problem already alluded to with the \identifier syntax is that it only works if the old Python version is sufficiently recent to understand \. What about using parentheses to

Re: [Python-ideas] Fwd: New suggested built in keyword: do

2018-06-08 Thread MRAB
On 2018-06-08 15:12, Randy Diaz wrote: I think that the keyword do would solve problems that occur when people want a simple way to run a command over an iterable but they dont want to store the data. example: do print(x) for x in range(50)      - this above command will not return

Re: [Python-ideas] Give regex operations more sugar

2018-06-13 Thread MRAB
On 2018-06-13 21:52, Chris Angelico wrote: On Thu, Jun 14, 2018 at 6:43 AM, Michel Desmoulin wrote: Le 13/06/2018 à 19:11, Mike Miller a écrit : On 2018-06-13 06:33, Michel Desmoulin wrote: I often wished for findall and sub to be string methods, so +1 on that. Agreed, and there are a

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread MRAB
On 2018-06-05 18:25, Kyle Lahnakoski wrote: I currently use the form     and log_function( ) where is some module variable, usually "DEBUG".  I do this because it is one line, and it ensures the log_function parameters are not evaluated. You'd get the same result with: if :

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-04 Thread MRAB
On 2018-06-05 01:25, Steven D'Aprano wrote: On Mon, Jun 04, 2018 at 02:22:29PM -0700, Ben Rudiak-Gould wrote: I'd like to propose adding `append` and `extend` methods to dicts which behave like `__setitem__` and `update` respectively, except that they raise an exception (KeyError?) instead of

Re: [Python-ideas] Fwd: Allow a group by operation for dict comprehension

2018-06-29 Thread MRAB
On 2018-06-29 05:14, David Mertz wrote: Mike Selik asked for my opinion on a draft PEP along these lines. I proposed a slight modification to his idea that is now reflected in his latest edits. With some details fleshed out, I think this is a promising idea. I like the a collections class

Re: [Python-ideas] A "local" pseudo-function

2018-05-01 Thread MRAB
On 2018-05-01 04:40, Tim Peters wrote: [MRAB] >> Any binding that's not specified as local is bound in the parent scope: [Tim] > Reverse-engineering the example following, is this a fair way of > making that more precise? > > Given a binding-target name N in scope S, N i

Re: [Python-ideas] A "local" pseudo-function

2018-05-01 Thread MRAB
On 2018-05-01 02:52, Tim Peters wrote: [MRAB <pyt...@mrabarnett.plus.com>] > ... > The intention is that only the specified names are local. > > After all, what's the point of specifying names after the 'local' if _any_ > binding in the local scope was loc

Re: [Python-ideas] A "local" pseudo-function

2018-05-01 Thread MRAB
On 2018-05-01 19:12, Tim Peters wrote: [MRAB] > Imagine renaming the specified names that are declared 'local' throughout > the nested portion: > > def f(): > a = 10 > local local_a: > def showa(): > print("a is", local_a) >

Re: [Python-ideas] A "local" pseudo-function

2018-05-01 Thread MRAB
allocated slots), so could the same kind of > thing be done for names in a local scope? Sorry, I'm unclear on what "inject a name into a local scope" means. Do you mean at runtime? I don't know what MRAB means by "inject", but I know what *I* mean, and I have a real use-c

Re: [Python-ideas] A "local" pseudo-function

2018-04-30 Thread MRAB
On 2018-04-30 21:41, Tim Peters wrote: [MRAB <pyt...@mrabarnett.plus.com>] > I think it should be lexically scoped. That's certainly arguable, but that's why I like real-code driven design: abstract arguments never end, and often yield a dubious in-real-life outcome after one side is

Re: [Python-ideas] A "local" pseudo-function

2018-04-29 Thread MRAB
rrent bindings until the `if` structure is done". >> >> So, >> >> if local(m1=regexp1.match(line), >>m2 = regexp2.match(iine), >>m1 and m2): >> >> intends to address both complaints via means embarrassingly obvious to >&g

Re: [Python-ideas] A "local" pseudo-function

2018-04-30 Thread MRAB
On 2018-04-30 03:49, Tim Peters wrote: [Soni L. ] That ain't shadow. That is dynamic scoping. I don't believe either term is technically accurate, but don't really care. Shadowing is something different: def f(): a = 42 def g(): print(a) local a:

Re: [Python-ideas] A "local" pseudo-function

2018-04-29 Thread MRAB
On 2018-04-29 07:57, Tim Peters wrote: [Tim Delaney ] My big concern here involves the: if local(m = re.match(regexp, line)): print(m.group(0)) example. The entire block needs to be implicitly local for that to work - what happens if I assign a new name in

Re: [Python-ideas] grouping / dict of lists

2018-07-03 Thread MRAB
On 2018-07-03 23:20, Greg Ewing wrote: Nicolas Rolin wrote: grouping(((len(word), word) for word in words)) That actually has one more level of parens than are needed, you can just write grouping((len(word), word) for word in words) FWIW, here's my opinion. I much prefer something

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2017-12-31 Thread MRAB
On 2017-12-31 08:13, Paddy3118 wrote: Hmm, yea I had not thought of how it would look - I had thought formost of not needing to necessarily learn about bitsets.when learning about passing a large number of optional flags to a function. Although the default could be None, interpreted as an

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-11 Thread MRAB
On 2018-01-11 19:42, Rob Speer wrote: > The question is rather: how often does web-XXX mojibake happen? Very often. Particularly web-1252 mixed up with UTF-8. My ftfy library is tested on data from Twitter and the Common Crawl, both prime sources of mojibake. One common mojibake sequence is

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread MRAB
On 2018-08-02 22:49, Eric Fahlgren wrote: On Thu, Aug 2, 2018 at 1:22 PM MRAB <mailto:pyt...@mrabarnett.plus.com>> wrote: > policy?.mangle_from_ ?? True > True (??? since lhs is None?) > No, it's not 'policy.mangle_from_' that could be None, it's 'poli

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread MRAB
On 2018-08-02 20:03, Eric Fahlgren wrote: From the PEP: > From email/generator.py (and importantly note that there is no way to substitute or for ?? in this situation): > mangle_from_ = True if policy is None else policy.mangle_from_ > After updating: > mangle_from_ =

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-31 Thread MRAB
On 2018-07-31 20:53, Jonathan Fine wrote: Stephan Houben wrote: Nope, the introduction of the tmp variable changed the semantics. It isn't a "chain" anymore so it breaks shortcutting. I'm confused. Assume 'a' is not defined. With Python's dot (attribute access) we have a.b.c NameError:

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-03 Thread MRAB
On 2018-08-03 23:05, Benedikt Werner wrote: There was a proposal to allow overloading boolean operators in Pep-335 [2], but that PEP was rejected for a variety of very good reasons.  I think none of those reasons (besides the conversation fizzling out) apply to my proposal. Maybe I am missing

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread MRAB
On 2018-08-13 20:08, Abe Dillon wrote: [Bruce Leban] Lambda calculus IS computer science. It's a foundation of computer science. That doesn't mean it "IS" computer science. Set theory is a foundation of computer science. It's still it's own discipline. [snip] The word "is" can mean,

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-15 Thread MRAB
On 2018-08-15 18:27, MRAB wrote: On 2018-08-15 09:17, Jonathan Fine wrote: Steve Barnes and Greg Ewing wrote: * A dinosaur is specifically an extinct terrible (formerly considered) lizard Which technically is not a lizard. I can't resist. Puffinus puffinus is the scientific name

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-15 Thread MRAB
On 2018-08-15 09:17, Jonathan Fine wrote: Steve Barnes and Greg Ewing wrote: * A dinosaur is specifically an extinct terrible (formerly considered) lizard Which technically is not a lizard. I can't resist. Puffinus puffinus is the scientific name for (drum roll) no, not the Atlantic

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread MRAB
On 2018-08-14 02:46, Michael Selik wrote: On Mon, Aug 13, 2018, 5:48 PM Greg Ewing > wrote: Chris Angelico wrote: > No, lambda calculus isn't on par with brakes - but anonymous functions > are, and if they're called "lambda", you just

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
def (x: int) -> int: x On Tue, Aug 21, 2018 at 6:28 PM MRAB <mailto:pyt...@mrabarnett.plus.com>> wrote: On 2018-08-22 01:25, Jonathan Fine wrote: > Hi Abe > > Summary: You've done good work here. I've skim read the 2006 > discussion you found.

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
On 2018-08-22 01:25, Jonathan Fine wrote: Hi Abe Summary: You've done good work here. I've skim read the 2006 discussion you found. You wrote: I'm trying to dig up past threads about alternatives to lambda because I would be astonished if "def" hadn't been considered and rejected for some

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-23 Thread MRAB
On 2018-08-23 03:10, Abe Dillon wrote: [Chris Angelico] Because your form cannot possibly work without some additional information. That isn't my form. That's PSEUDO CODE. Just like I wrote above it. You're the one who's not listening.  The alternative I've suggested, for the

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread MRAB
On 2018-08-22 23:44, Greg Ewing wrote: Steven D'Aprano wrote: Not "process the sorted list", but reify the sort verb into an actual thing (an object or value) and then process that thing itself. This is mind-bending when you think about it, far more mind-blowing than the normal linguistic

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread MRAB
On 2018-08-24 16:27, Mike Barnett wrote: Liking the comments Paul! [snip] It has the call information about the Text widget and all the others. Is this what you mean by a Signature? Text(Text, scale=(None, None), size=(None, None), auto_size_text=None, font=None,

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-08-28 Thread MRAB
On 2018-08-28 18:57, Guido van Rossum wrote: So we currently have iterable unpacking:   a, b, c = x  # x better be an iterable of exactly 3 values as well as tuple packing:   x = a, b, c  # sets x to a tuple of 3 values (a, b, c) and we can combine these, e.g.:   a, b, c = x, y, z and

Re: [Python-ideas] Make import an expression

2018-07-14 Thread MRAB
On 2018-07-14 10:39, Jonathan Fine wrote: Hi Ken Thank you for your clear subject line. As you probably already know, in Python, assignments are not expressions, and so we can't write    if (a=get()):        # do something with a One reason for this is, perhaps, that "Explicit is better

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-16 Thread MRAB
On 2018-07-16 05:24, Chris Angelico wrote: On Mon, Jul 16, 2018 at 1:21 PM, Nathaniel Smith wrote: On Sun, Jul 15, 2018 at 6:00 PM, Chris Angelico wrote: On Mon, Jul 16, 2018 at 10:31 AM, Nathaniel Smith wrote: On Sun, Jul 8, 2018 at 11:27 AM, David Foster wrote: * The Actor model can be

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-23 Thread MRAB
On 2018-07-23 13:04, Giampaolo Rodola' wrote: On Mon, Jul 23, 2018 at 3:12 AM Steven D'Aprano wrote: > ? has no spaces, it's literally "variable names interrupted by > question marks" and evaluation can stop at any time while scanning the > line from left to right. Just like ordinary

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-23 Thread MRAB
On 2018-07-23 23:05, Giampaolo Rodola' wrote: On Mon, Jul 23, 2018 at 6:53 PM Steven D'Aprano wrote: On Mon, Jul 23, 2018 at 02:04:17PM +0200, Giampaolo Rodola' wrote: > "a?.b" does two and that's a fundamental difference (explicitness). How is "two things" less explicit than "one thing"?

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread MRAB
On 2018-07-19 14:26, Stephan Houben wrote: FWIW, I like ?? It is short and distinctive. There is prior art in this spelling in c#. It requires no new keyword, nor does it give new meaning to an existing one. I understand why  ?[ needs to be spelled using only a single ?, but I am afraid it

Re: [Python-ideas] Multi-core reference count garbage collection

2018-07-19 Thread MRAB
On 2018-07-19 11:53, Jonathan Fine wrote: Hi Stephan Thank you for the extract from the GC Handbook, which I think I may have seen before. Yes, it is GOOD that it's an already known idea. Searching for "buffered reference counting" I found

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread MRAB
On 2018-07-19 16:22, Calvin Spealman wrote: If its treated as a missing parameter, and currently doesn't do anything, then it wouldn't be used... right? and it could be safe to add behavior for it... right? Are you sure that it wouldn't break some existing code? Plus, we already have

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread MRAB
On 2018-07-19 20:23, Terry Reedy wrote: On 7/19/2018 8:30 AM, Jonathan Fine wrote: Hi There is a formatted version of this PEP at https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread MRAB
On 2018-07-18 18:43, Steve Dower wrote: Possibly this is exactly the wrong time to propose the next big syntax change, since we currently have nobody to declare on it, but since we're likely to argue for a while anyway it probably can't hurt (and maybe this will become the test PEP for whoever

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-18 Thread MRAB
On 2018-07-18 20:35, Eric Snow wrote: On Wed, Jul 18, 2018 at 12:49 PM Stephan Houben wrote: Antoine said that what I proposed earlier was very similar to what Eric is trying to do, but from the direction the discussion has taken so far that appears not to be the case. It looks like we are

Re: [Python-ideas] Unicode Name Aliases keyword argument abbreviation in unicodedata.name for missing names

2018-07-12 Thread MRAB
On 2018-07-12 16:02, Stephen J. Turnbull wrote: Robert Vanden Eynde writes: > As I'm at, I mentionned the ffef character but we don't care about > it because it already has a name, so that's mostly a control > character issue. The problem with control characters is that from the point of

Re: [Python-ideas] Add MutableSet.update?

2018-03-09 Thread MRAB
On 2018-03-10 01:15, Guido van Rossum wrote: Yes, you can use the |= operator instead. |= is not quite the same as .update because it rebinds, so if the name on the LHS isn't local it'll raise NameError. Does that matter? On Fri, Mar 9, 2018 at 4:48 PM, Lucas Wiman

  1   2   3   4   >