Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 8:07 AM, Mike Miller wrote: > On 2018-04-20 14:59, Jelle Zijlstra wrote: >> In other words, the with statement would continue to require an as >> clause >> outside of the parentheses. A double name binding doesn't seem very >> useful >> however. >> >> The with

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 11:38 AM, Anthony Flury via Python-Dev wrote: > I am entirely new to this list, but if I can I would like share my comments > : > > * I do think this proposal := has merit in my >opinion; it does make some code more readable. > > * I think readability is only improv

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-21 Thread Chris Angelico
On Sat, Apr 21, 2018 at 5:11 PM, Steven D'Aprano wrote: > On Sat, Apr 21, 2018 at 12:30:36PM +1000, Chris Angelico wrote: >> Introducing expression assignments will make these oddities even more >> obvious. You'd be able to demonstrate things like this at function >&g

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-21 Thread Chris Angelico
On Sat, Apr 21, 2018 at 6:38 PM, Anthony Flury via Python-Dev wrote: > On 21/04/18 08:46, Chris Angelico wrote: >> >> doubled_items = [x for x in (items := get_items()) if x * 2 in items] >> >> This will leak 'items' into the surrounding scope (but not 'x

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-21 Thread Chris Angelico
On Sat, Apr 21, 2018 at 7:12 PM, Paul Moore wrote: > On 21 April 2018 at 03:30, Chris Angelico wrote: >> There's that word "readability" again. Sometimes I wish the Zen of >> Python didn't use it, because everyone seems to think that "readable&quo

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-21 Thread Chris Angelico
On Sat, Apr 21, 2018 at 10:26 PM, Steven D'Aprano wrote: > On Sat, Apr 21, 2018 at 05:46:44PM +1000, Chris Angelico wrote: >> On Sat, Apr 21, 2018 at 5:11 PM, Steven D'Aprano wrote: > >> > So can you explain specifically what odd function-scope behaviour you

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-21 Thread Chris Angelico
vior > 5. with (closing(urlopen(url)) as dl): # same > > 4. with closing(urlopen(url) as dl): # urlopener named early > > > On 2018-04-20 17:15, Chris Angelico wrote: >> >> The second and fifth could be special cased as either the same as >> first and

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-22 Thread Chris Angelico
On Sun, Apr 22, 2018 at 7:29 PM, Christoph Groth wrote: > If I had to choose between the above and ":= binding expressions", I > guess I would tend to prefer the latter because they are sufficient, > nicer looking and offer less potential for trouble. But I think that it > is worth to fully discu

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-22 Thread Chris Angelico
On Mon, Apr 23, 2018 at 6:22 AM, Mike Miller wrote: > On 2018-04-22 12:37, Chris Angelico wrote: >> Kinda, except that that's not quite a match either. But mainly, the >> comparison with 'with' and 'except' is dangerously incompatible. > > Hmm, looks

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-22 Thread Chris Angelico
On Mon, Apr 23, 2018 at 8:20 AM, Mike Miller wrote: > > On 2018-04-22 14:33, Chris Angelico wrote: >> >> with open(fn) as f: >> with (open(fn) as f): >> >> These two do the same thing, but only because a file object's >> __enter__ returns self.

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-23 Thread Chris Angelico
On Tue, Apr 24, 2018 at 3:13 AM, Sven R. Kunze wrote: > On 23.04.2018 17:59, Steve Holden wrote: > > > While Tim's expression might look (superficially) like C, the five-line > alternative isn't exactly an inspiring example of Pythonicity, is it? > > > What about > > diff = x - x_base > if diff an

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-23 Thread Chris Angelico
On Tue, Apr 24, 2018 at 6:21 AM, Sven R. Kunze wrote: > On 23.04.2018 19:24, Chris Angelico wrote: >> >> On Tue, Apr 24, 2018 at 3:13 AM, Sven R. Kunze wrote: >>> >>> diff = x - x_base >>> if diff and gcd(diff, n) > 1: >>> return gcd(d

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-23 Thread Chris Angelico
On Tue, Apr 24, 2018 at 7:25 AM, Sven R. Kunze wrote: > On 23.04.2018 22:37, Chris Angelico wrote: >> >> Ah, are you one of those programmers who writes code once and it's >> instantly perfect? I apologize, I didn't realize I was in the presence >> of a unic

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-23 Thread Chris Jerdonek
- x_base, and g, which ..." or "if diff, which we set equal to x - x_base, and g, which " or "if diff, which we define to be x - x_base, and g, which " or "if diff, which we define as x - x_base, and g, which ." etc. --Chris > > From my Pascal

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-23 Thread Chris Angelico
On Tue, Apr 24, 2018 at 4:27 PM, Antoine Pitrou wrote: > On Tue, 24 Apr 2018 01:06:30 -0500 > Tim Peters wrote: >> >> > - does it make Python easier to learn and teach? >> >> By whom? Almost no addition has ever made a language easier to learn >> for raw beginners: every addition is something t

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-24 Thread Chris Angelico
On Tue, Apr 24, 2018 at 5:12 PM, Greg Ewing wrote: > Chris Jerdonek wrote: > >>>> if (diff := x - x_base) and (g := gcd(diff, n)) > 1: > > >> "if diff, which we let equal x - x_base, and g, which ..." or >> "if diff, which we set equal to x

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-24 Thread Chris Angelico
On Tue, Apr 24, 2018 at 5:23 PM, Greg Ewing wrote: > Stephen J. Turnbull wrote: >> >> Neologisms are usually written in the >> other order: "dead on arrival (DOA, for short)." ;-) > > > Maybe we can make use of that? > >if (x - x_base) (diff) and gcd(diff, n) (g) > 1: > > That doesn't work, be

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 12:23 AM, Yury Selivanov wrote: > On Tue, Apr 24, 2018 at 10:07 AM, Nick Coghlan wrote: > >>> "=" is always an assignment. >>> "==" is always an equality check. >> >> That's not the distinction I meant, I meant the difficulty of >> explaining the discrepancies in this list

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 12:54 AM, Anthony Flury via Python-Dev wrote: > As discussed previously by others on this exact proposals, you now have the > issue of confusion when using keyword arguments : *my_func(a = b)* : > clearly that is a call to `my_func' where argument a has the value of b, but

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 1:03 AM, Yury Selivanov wrote: > On Tue, Apr 24, 2018 at 10:56 AM, Chris Angelico wrote: > [..] >>> A lot of other questions arise though. PEP 572 proposes: >>> >>> a = 1 # assignment >>> a := 1 # also assignment >>&g

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 12:58 AM, Yury Selivanov wrote: > On Tue, Apr 24, 2018 at 10:49 AM, Paul Moore wrote: > [..] 3. Most importantly: it is *not* allowed to mask names in the current local scope. >>> >>> While I agree this would be unambiguous to a computer, I think for >>> most hum

[Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-24 Thread Chris Angelico
: Chris Angelico Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 28-Feb-2018 Python-Version: 3.8 Post-History: 28-Feb-2018, 02-Mar-2018, 23-Mar-2018, 04-Apr-2018, 17-Apr-2018, 25-Apr-2018 Abstract This is a proposal for creating a way to assign to

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 1:15 AM, Steven D'Aprano wrote: > By the way, the check for existing variables cannot help to be either > incomplete or incorrect if you try to do it at compile time: > > > from module import * > (x = 2) # allowed or not allowed? > > > If you don't like wild-card i

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 1:49 AM, Yury Selivanov wrote: > On Tue, Apr 24, 2018 at 11:34 AM, Steven D'Aprano wrote: >> On Tue, Apr 24, 2018 at 11:05:57AM -0400, Yury Selivanov wrote: >> >>> Well, `my_func(a=(b:=foo))` or `my_func(b:=foo)` are also barely >>> readable to my eye. >> >> There's no adv

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 1:56 AM, Yury Selivanov wrote: > On Tue, Apr 24, 2018 at 11:51 AM, Ethan Furman wrote: > >>> When I compare to variables from outer scopes they *usually* are on >>> the *right* side of '=='. >> >> >> You mean something like >> >> if 2 == x: >> >> ? I never write code li

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 2:28 AM, Steven D'Aprano wrote: > On Tue, Apr 24, 2018 at 10:58:24AM -0400, Yury Selivanov wrote: > >> Since 'diff' and 'g' must be new names according to rule (3), those >> who read the code will notice that both were not previously bound. > > How am I supposed to notice t

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 2:23 AM, Steven D'Aprano wrote: > On Tue, Apr 24, 2018 at 11:25:58AM -0400, Yury Selivanov wrote: > >> No, it doesn't. The check is performed during compile phase, and >> Python does not unroll loops. Anyways, read below. > > What does unrolling loops have to do with anythi

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 2:40 AM, Tim Peters wrote: > [Antoine] >> ... >> Yes... I think most will agree that Python is generally easy to take up >> for people coming from C++ etc., so my "easier to learn and teach" was >> mostly about non-programmers. > > [Tim] >>> even for raw beginners the seman

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 2:57 AM, Steven D'Aprano wrote: > On Wed, Apr 25, 2018 at 02:42:08AM +1000, Chris Angelico wrote: > >> > from math import * >> > process(arg, (pi = 1), pi+1) # allowed > > >> That's not allowed at local scope (at lea

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 5:54 AM, Mike Miller wrote: > Also, these "binding expressions" are not exactly plain assignment, as it > has been known. Aside from the restriction to binding only to a simple name, and the fact that they're also an expression with the same value, how are they not the sam

Re: [Python-Dev] assignment expressions: an alternative proposal

2018-04-24 Thread Chris Angelico
On Wed, Apr 25, 2018 at 7:29 AM, Anthony Flury via Python-Dev wrote: > On 24/04/18 17:11, Yury Selivanov wrote: >> >> On Tue, Apr 24, 2018 at 12:03 PM, Ethan Furman wrote: >> [..] >>> >>> But I do write this: >>> >>>def wrapper(func, some_value): >>> value_I_want = process(some_value) >>

Re: [Python-Dev] PEP 572: Write vs Read, Understand and Control Flow

2018-04-24 Thread Chris Angelico
nt and I'm surprised nobody has thought of it > until now (that I've seen). > > Chris, if you're still reading this and aren't yet heartedly sick and > tired of the PEP *wink* this ought to go in as another motivating point. > Yes, I'm still reading... but I

Re: [Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-25 Thread Chris Angelico
On Wed, Apr 25, 2018 at 4:55 PM, Nathaniel Smith wrote: > On Tue, Apr 24, 2018 at 8:31 AM, Chris Angelico wrote: >> The most notable change since last posting is that the assignment >> target is no longer as flexible as with the statement form of >> assignment, but is restri

Re: [Python-Dev] assignment expressions: an alternative alternative proposal

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 1:46 AM, Guido van Rossum wrote: > On Wed, Apr 25, 2018 at 2:27 AM, Steve Holden wrote: >> >> On Wed, Apr 25, 2018 at 6:16 AM, Steven D'Aprano >> wrote: >>> >>> On Tue, Apr 24, 2018 at 03:54:30PM -0700, Guido van Rossum wrote: >>> >>> > We should really take this back to

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 6:21 AM, Łukasz Langa wrote: > := also goes against having one obvious way to do it. Since it's an > expression, > it can also be placed on its own line or in otherwise weird places like > function call arguments. I anticipate PEP 8 would have to be extended to > explicitl

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 8:08 AM, Antoine Pitrou wrote: > On Wed, 25 Apr 2018 16:55:43 -0500 > Tim Peters wrote: >> >> To my eyes, this is genuinely harder to follow, despite its relative brevity: >> >> while total != (total := total + term): > > Does it even work? Perhaps if the goal is

Re: [Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 9:05 AM, Victor Stinner wrote: >> # Handle a matched regex >> if (match := pattern.search(data)) is not None: >> ... >> >> # A more explicit alternative to the 2-arg form of iter() invocation >> while (value := read_next_item()) is not None: >>

Re: [Python-Dev] Visual similarity of "=" and "==" (in context of PEP 572)

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 9:54 AM, Mikhail V wrote: > Since the discussion about operator choice has completely migrated > here, I'll put my note also here. > From the very beginning of PEP 572 discussion I have noticed > a strange fact - there is told a lot about visual similarity > of "=" and "=="

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 10:11 AM, Yury Selivanov wrote: > Just yesterday this snippet was used on python-dev to show how great the > new syntax is: > > my_func(arg, buffer=(buf := [None]*get_size()), size=len(buf)) > > To my eye this is an anti-pattern. One line of code was saved, but t

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 3:34 PM, Steven D'Aprano wrote: > On Thu, Apr 26, 2018 at 05:22:58PM +1200, Greg Ewing wrote: >> Łukasz Langa wrote: >> >What was its own assignment before >> >now is part of the logic test. This saves on vertical whitespace but makes >> >parsing and understanding logic tes

Re: [Python-Dev] PEP 572: Write vs Read, Understand and Control Flow

2018-04-25 Thread Chris Angelico
On Thu, Apr 26, 2018 at 3:54 PM, Stephen J. Turnbull wrote: > Chris Angelico writes: > > > Additionally, naming sub-parts of a large expression can assist an > > interactive debugger, providing useful display hooks and partial > > results. Without a way to capture sub-

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-26 Thread Chris Angelico
On Thu, Apr 26, 2018 at 6:30 PM, Antoine Pitrou wrote: > On Thu, 26 Apr 2018 17:29:17 +1000 > Steven D'Aprano wrote: >> On Thu, Apr 26, 2018 at 07:16:28PM +1200, Greg Ewing wrote: >> > Tim Peters wrote: >> > >As a statement in a program (as opposed to typed at a shell), >> > >"a := 3" has the unn

Re: [Python-Dev] PEP 572: Write vs Read, Understand and Control Flow

2018-04-26 Thread Chris Angelico
On Thu, Apr 26, 2018 at 9:23 PM, Stephen J. Turnbull wrote: > Chris Angelico writes: > > > Well, true. The point isn't WHO you're dictating to, > > By "period here preferred," I meant I think it's mostly a waste of > space to mention dictation at al

Re: [Python-Dev] PEP 572: Why not := as standard assignment operator?

2018-04-26 Thread Chris Angelico
On Thu, Apr 26, 2018 at 11:13 PM, Martin Teichmann wrote: > Hi list, > > when reading PEP 572 I actually liked it a lot - I think it's actually > a cool idea. I think it's actually that cool an idea that it should be > made the default way of doing an assignment, over time phasing out the > good o

Re: [Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-26 Thread Chris Angelico
Nick Coghlan wrote: >> >> On 25 April 2018 at 18:23, Chris Angelico wrote: >> >>>> x={print(2): print(1) for _ in [1]} >> > 1 >> > 2 >> > >> > Hm. One of these is not like the others... >> >> Huh, it looks like

Re: [Python-Dev] PEP 572: Why not := as standard assignment operator?

2018-04-26 Thread Chris Angelico
On Fri, Apr 27, 2018 at 1:38 AM, Gustavo Carneiro wrote: > > > On 26 April 2018 at 16:18, Chris Angelico wrote: >> >> On Thu, Apr 26, 2018 at 11:13 PM, Martin Teichmann >> wrote: >> > Hi list, >> > >> > when reading PEP 572 I actually like

Re: [Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-26 Thread Chris Angelico
On Fri, Apr 27, 2018 at 2:02 AM, Guido van Rossum wrote: > Maybe the order for d[k] = v should also be reconsidered? If so, it would be something like: 1) Evaluate d 2) Evaluate k 3) Evaluate v 4) Call d.__setitem__(k, v), via slots etc In a vacuum, I don't have a problem with that. But I suspe

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-26 Thread Chris Angelico
On Fri, Apr 27, 2018 at 3:33 AM, Sven R. Kunze wrote: > On 25.04.2018 01:19, Steven D'Aprano wrote: >> >> Sorry, gcd(diff, n) is not the "perfect name", and I will tell you that >> sometimes g is better. [...] > > > We were talking about the real-world code snippet of Tim (as a justification > of

Re: [Python-Dev] The new and improved PEP 572, same great taste with 75% less complexity!

2018-04-26 Thread Chris Angelico
On Fri, Apr 27, 2018 at 4:07 AM, Larry Hastings wrote: > * I assume that--if we don't already have one--we'll add a new > DUP_AND_STORE_FAST opcode for binding expressions. On the other hand, > "STORE_FAST n" followed by "LOAD_FAST n" is a common enough bytecode idiom > that the peephole optimize

Re: [Python-Dev] Order of positional and keyword arguments

2018-04-27 Thread Chris Jerdonek
ed changing-- def create_cursor(self, name=None): to-- def create_cursor(self, name=None, *args, **kwargs): https://github.com/django/django/pull/9674/files#diff-53fcf3ac0535307033e0cfabb85c5301R173 --Chris > > This will also make the grammar simpler. Current

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-27 Thread Chris Angelico
On Fri, Apr 27, 2018 at 8:18 PM, Wes Turner wrote: > IDK, I could just be resistant to change, but this seems like something that > will decrease readability -- and slow down code review -- without any real > performance gain. So, while this would be useful for golfed-down (!) > one-liners with py

Re: [Python-Dev] PEP 572: Write vs Read, Understand and Control Flow

2018-04-27 Thread Chris Barker
On Tue, Apr 24, 2018 at 2:21 AM, Victor Stinner wrote: > Even if the C language allows assignments in if, I avoid them, because > I regularly have to debug my own code in gdb ;-) > I personally haven't written a lot of C, so have no personal experience, but if this is at all a common approach am

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-27 Thread Chris Barker
On Thu, Apr 26, 2018 at 1:33 PM, Tim Peters wrote: > And that *is* a thing that you will have to explain to newbies when they > encounter > > it for the first time. > > Sure. That doesn't frighten me, though. It's easy to explain what it > does - although it may be hard to explain when it's _d

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-27 Thread Chris Angelico
On Sat, Apr 28, 2018 at 6:06 AM, Wes Turner wrote: > > > On Friday, April 27, 2018, Chris Angelico wrote: >> >> On Fri, Apr 27, 2018 at 8:18 PM, Wes Turner wrote: >> > IDK, I could just be resistant to change, but this seems like something >> > that >

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-27 Thread Chris Angelico
On Sat, Apr 28, 2018 at 6:24 AM, Wes Turner wrote: > > > On Friday, April 27, 2018, Chris Angelico wrote: >> >> On Sat, Apr 28, 2018 at 6:06 AM, Wes Turner wrote: >> > >> > >> > On Friday, April 27, 2018, Chris Angelico wrote: >>

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-27 Thread Chris Angelico
On Sat, Apr 28, 2018 at 7:11 AM, Tim Peters wrote: > [Chris Angelico ] >> ... >> I don't understand why people bring up all these arguments that have >> absolutely nothing to do with the proposal at hand. None of this has >> in any way changed. > > That'

Re: [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

2018-04-28 Thread Chris Angelico
On Sat, Apr 28, 2018 at 9:18 PM, Ned Batchelder wrote: > It's entirely true that binding expressions don't change this situation at > all, EXCEPT that the entire point of binding expressions is to be able to > express in one statement what used to take more than one. With binding > expressions, a

Re: [Python-Dev] PEP 572 contradicts PEP 3099

2018-04-28 Thread Chris Angelico
On Sun, Apr 29, 2018 at 1:11 PM, Alex Walters wrote: > > >> -Original Message- >> From: Python-Dev > [email protected]> On Behalf Of Greg Ewing >> Sent: Saturday, April 28, 2018 10:53 PM >> To: 'Python-Dev' >> Subject: Re: [Python-Dev] PEP 572 contradicts PEP 3099 >> >> Alex Walt

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-30 Thread Chris Angelico
On Tue, May 1, 2018 at 12:30 AM, Mark Shannon wrote: > List comprehensions > --- > The PEP uses the term "simplifying" when it really means "shortening". > One example is > stuff = [[y := f(x), x/y] for x in range(5)] > as a simplification of > stuff = [(lambda y: [y,x/y])(f(x)) fo

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-30 Thread Chris Angelico
On Tue, May 1, 2018 at 2:53 AM, Yury Selivanov wrote: > On Mon, Apr 30, 2018 at 11:32 AM Chris Angelico wrote: > >> On Tue, May 1, 2018 at 12:30 AM, Mark Shannon wrote: >> > List comprehensions >> > --- >> > The PEP uses the term "s

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-04-30 Thread Chris Jerdonek
eturn stashed[0] There are many variations to this idea, obviously. For example, one could allow passing a "name" to stash(), or combine stash / stashed into a single, callable object that allows setting and reading from its store. I wonder if one

Re: [Python-Dev] PEP 572: Assignment Expressions

2018-05-01 Thread Chris Jerdonek
On Tue, May 1, 2018 at 2:14 AM, Steve Holden wrote: > On Tue, May 1, 2018 at 3:36 AM, Chris Jerdonek > wrote: >> >> On Thu, Apr 26, 2018 at 10:33 AM, Sven R. Kunze wrote: >> > On 25.04.2018 01:19, Steven D'Aprano wrote: >> >> >> >> Sorry,

Re: [Python-Dev] Python startup time

2018-05-03 Thread Chris Angelico
On Fri, May 4, 2018 at 10:43 AM, Gregory P. Smith wrote: > I'd also like to see this concept somehow extended to decorators so that the > results of the decoration can be captured in the compiled pyc rather than > requiring execution at import time. I realize that limits what decorators > can do,

Re: [Python-Dev] Python startup time

2018-05-03 Thread Chris Jerdonek
17-October/149670.html At the end Guido kicked (at least part of) the discussion back to python-ideas. --Chris On Thu, May 3, 2018 at 5:55 PM, Chris Angelico wrote: > On Fri, May 4, 2018 at 10:43 AM, Gregory P. Smith wrote: > > I'd also like to see this concept somehow extend

Re: [Python-Dev] Dealing with tone in an email

2018-05-05 Thread Chris Angelico
On Sun, May 6, 2018 at 10:22 AM, Ivan Pozdeev via Python-Dev wrote: > Well, this _is_ a big deal. As in, "with 15+ years of experience, 5+ with > Python, I failed to produce a working GUI in a week; no-one on the Net, > regardless of experience, (including Terry) is ever sure how to do things > ri

Re: [Python-Dev] Dealing with tone in an email

2018-05-05 Thread Chris Angelico
On Sun, May 6, 2018 at 11:39 AM, Steven D'Aprano wrote: > On Sun, May 06, 2018 at 11:09:21AM +1000, Chris Angelico wrote: > >> What exactly didn't work? I don't understand. > > https://bugs.python.org/issue33412 > I've read it and I still don't full

Re: [Python-Dev] Dealing with tone in an email

2018-05-06 Thread Chris Angelico
On Sun, May 6, 2018 at 6:54 PM, Terry Reedy wrote: >> Is it ALL of Tkinter that fails in threaded mode? > > No. It is non-threaded tcl that fails in threaded mode, along with > tkinter's attempt to make non-thread tcl work anyway. There are at least > two different cases. > > Ivan has clarified

Re: [Python-Dev] Dealing with tone in an email

2018-05-06 Thread Chris Angelico
On Mon, May 7, 2018 at 6:04 AM, Terry Reedy wrote: > On 5/6/2018 10:03 AM, Chris Angelico wrote: >> If it were up to me, I would deprecate non-threaded mode immediately, > > > Given that 99% of tkinter users do not need threaded tcl, why cut some of > them off? "Non-t

Re: [Python-Dev] Process to remove a Python feature

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 2:53 AM, Serhiy Storchaka wrote: > 08.05.18 19:10, Ethan Furman пише: >>> >>> X.Y+1: added a deprecation warning. Many users need to support only two >>> recent versions and can move to using the >>> replacement now. >> >> >> I'm curious how you arrived at this conclusion?

[Python-Dev] Associated images in PEPs broken?

2018-05-11 Thread Chris Angelico
https://www.python.org/dev/peps/pep-0495/ All the images seem to be missing - showing up 404. They're in the peps repository, but aren't showing up in the page. Who's in charge of the HTML rendering there? Infrastructure? ChrisA ___ Python-Dev mailing l

Re: [Python-Dev] Associated images in PEPs broken?

2018-05-11 Thread Chris Angelico
On Fri, May 11, 2018 at 9:33 PM, Chris Angelico wrote: > https://www.python.org/dev/peps/pep-0495/ > > All the images seem to be missing - showing up 404. They're in the > peps repository, but aren't showing up in the page. Who's in charge of > the HTML rendering the

Re: [Python-Dev] PEP 572 and f-strings

2018-05-12 Thread Chris Angelico
On Sat, May 12, 2018 at 9:11 PM, Eric V. Smith wrote: > I don't think it matters to its acceptance, but PEP 572 should at least > mention that the := syntax means that you cannot use assignment expressions > in f-strings. > > As I wrote in a python-ideas email, f'{x:=4}' already has a defined mean

[Python-Dev] Looking for examples: proof that a list comp is a function

2018-05-14 Thread Chris Angelico
Guido has stated that this parallel is desired and important: result = [f(x) for x in iter if g(x)] result = list(f(x) for x in iter if g(x)) Obviously the genexp has to be implemented with a nested function, since there's no guarantee that it'll be iterated over in this way. With current semanti

Re: [Python-Dev] What is the rationale behind source only releases?

2018-05-15 Thread Chris Angelico
On Wed, May 16, 2018 at 3:06 PM, Ben Finney wrote: > "Alex Walters" writes: > >> I'd like to know the rationale behind source only releases of cpython. > > Software freedom entails the freedom to modify and build the software. > For that, one needs the source form of the software. > > Portable so

Re: [Python-Dev] What is the rationale behind source only releases?

2018-05-15 Thread Chris Jerdonek
What does “no release at all” mean? If it’s not released, how would people use it? —Chris On Tue, May 15, 2018 at 9:36 PM Alex Walters wrote: > In the spirit of learning why there is a fence across the road before I > tear > it down out of ignorance [1], I'd like to know the ra

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Chris Angelico
On Thu, May 17, 2018 at 5:21 PM, Anthony Flury via Python-Dev wrote: > Victor, > Thanks for the link, but to be honest it will just confuse people - neither > the link or the related bpo entries state that the fix is only limited to > strings. They simply talk about hash randomization - which in m

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Chris Angelico
On Fri, May 18, 2018 at 12:15 AM, Anthony Flury via Python-Dev wrote: > Chris, > I entirely agree. The same questioner also asked about the fastest data type > to use as a key in a dictionary; and which data structure is fastest. I get > the impression the person is very into micro-

Re: [Python-Dev] My fork lacks a 3.7 branch - can I create it somehow?

2018-05-21 Thread Chris Angelico
On Tue, May 22, 2018 at 10:07 AM, Skip Montanaro wrote: > My GitHub fork of the cpython repo was made awhile ago, before a 3.7 branch > was created. I have no remotes/origin/3.7. Is there some way to create it > from remotes/upstream/3.7? I asked on GitHub's help forums. The only > recommendation

Re: [Python-Dev] My fork lacks a 3.7 branch - can I create it somehow?

2018-05-21 Thread Chris Angelico
On Tue, May 22, 2018 at 10:45 AM, Skip Montanaro wrote: >> Create it from upstream? Yep! Try this: > >> git checkout -b 3.7 upstream/3.7 >> git push -u origin 3.7 > > Thanks, Chris! Didn't have to chug for too long either, just a few seconds. > > S Perfect

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Chris Angelico
On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: > Hi, > > I just read a recent bugfix in asyncio: > > https://github.com/python/cpython/commit/9602643120a509858d0bee4215d7f150e6125468 > > + try: > + await waiter > + except Exception: > + transport.close() > + raise > > Why only c

Re: [Python-Dev] Why not using "except: (...) raise" to cleanup on error?

2018-06-04 Thread Chris Angelico
On Tue, Jun 5, 2018 at 2:57 AM, Yury Selivanov wrote: > On Mon, Jun 4, 2018 at 12:50 PM Chris Angelico wrote: >> >> On Tue, Jun 5, 2018 at 2:11 AM, Victor Stinner wrote: > [..] >> > For me, it's fine to catch any exception using "except:" if the block

Re: [Python-Dev] Microsoft to acquire GitHub for $7.5 b

2018-06-06 Thread Chris Jerdonek
grant us > are limited to those we need to provide the service.* > Is the “service” they provide (and what it needs) allowed to change over time, so that the rights granted can expand? The definition of “service” in their document is— 1. The “Service” refers to the applications, software,

Re: [Python-Dev] Microsoft to acquire GitHub for $7.5 b

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 3:33 AM, Chris Barker - NOAA Federal via Python-Dev wrote: > Any service could change or fail. Period. > > So we shouldn’t want valuable information about Python development > only in gitHub. > > I don’t know how hard it is to backup / mirror an entire re

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-22 Thread Chris Angelico
On Sat, Jun 23, 2018 at 3:02 AM, Michael Selik wrote: > On Fri, Jun 22, 2018 at 8:09 AM Antoine Pitrou wrote: >> >> Thank you. Personally, I'd like to see feedback from >> educators/teachers after they take the time to read the PEP and take >> some time to think about its consequences. > > > I'v

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-22 Thread Chris Angelico
On Sat, Jun 23, 2018 at 1:48 PM, Steven D'Aprano wrote: > I can't say I've done a broad survey, but the third-party documentation > I've read on comprehensions typically glosses over the scoping issues > without mentioning them. To the extent that scoping is even hinted at, > comprehensions are tr

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 4:33 PM, Nick Coghlan wrote: > On 24 June 2018 at 15:56, Steven D'Aprano wrote: >> On Sun, Jun 24, 2018 at 02:33:59PM +1000, Nick Coghlan wrote: >> >>> Given that PEP 572 *is* proposing implicit comprehension state export, >> >> "Implicit" and "explicit" are two terms whic

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-24 Thread Chris Angelico
On Mon, Jun 25, 2018 at 4:06 AM, Steven D'Aprano wrote: > > Remember, the driving use-case which started this (ever-so-long) > discussion was the ability to push data into a comprehension and then > update it on each iteration, something like this: > > x = initial_value() > results = [x :=

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-25 Thread Chris Angelico
On Tue, Jun 26, 2018 at 5:37 AM, Terry Reedy wrote: > How loop variables might be isolated without a nested scope: After a > comprehension is parsed, so that names become strings, rename the loop > variables to something otherwise illegal. For instance, i could become > '', just as lambda becomes

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-27 Thread Chris Angelico
On Wed, Jun 27, 2018 at 5:30 PM, Paul Moore wrote: > But test() returns [1, 2]. So does that say (as you claim above) that > "the comprehension ran in the enclosing scope"? Doesn't it just say > that the outermost iterable runs in the enclosing scope? Yes - because the *outermost iterable* runs i

Re: [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

2018-06-27 Thread Chris Angelico
On Wed, Jun 27, 2018 at 7:19 PM, Steven D'Aprano wrote: > On Wed, Jun 27, 2018 at 05:52:16PM +1000, Chris Angelico wrote: > >> def test(): >> a = 1 >> b = 2 >> vars = {key: locals()[key] for key in locals()} >> return vars >> &

[Python-Dev] PEP 485 isclose() implementation review requested

2015-05-17 Thread Chris Barker
iewed but in the meantime, i welcome any feedback. Thanks, -Chris A few questions I have off the bat: C-API (and plain C) questions: = * Is there a better way to create a False or True than:: PyBool_FromLong(0) and PyBool_FromLong(1) * Style question: shoul

Re: [Python-Dev] PEP 485 isclose() implementation review requested

2015-05-18 Thread Chris Barker
e handling the docsstrings better and some more/better tests. -Chris On Sun, May 17, 2015 at 4:16 PM, Christian Heimes wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA512 > > On 2015-05-18 01:02, Chris Barker wrote: > > * Is there a better way to

Re: [Python-Dev] Gcode path

2015-05-18 Thread Chris Barker
installed, you will get the confusing error something like "python is not installed", when it really means "the correct version of python is not installed". So make sure you see which version Replicatorg is expecting and make sure that's the one you installed. Good luck, -Chri

Re: [Python-Dev] Reminder: Python 3.5 beta 1 will be tagged tomorrow

2015-05-22 Thread Chris Barker
done soon -- if so, how? -Chris On Fri, May 22, 2015 at 12:53 PM, Larry Hastings wrote: > > > Howdy howdy. It's-a me, Larry, your friendly neighborhood Python 3.5 > Release Manager. > > Somewhere around 2 or 3pm tomorrow I expect to tag Python 3.5 beta 1. > We'

Re: [Python-Dev] Reminder: Python 3.5 beta 1 will be tagged tomorrow

2015-05-22 Thread Chris Barker
On Fri, May 22, 2015 at 2:33 PM, Larry Hastings wrote: > On 05/22/2015 02:29 PM, Chris Barker wrote: > > Is it too late to get the isclose() code (PEP 485) into 3.5? > > ... > Hopefully you can find a core dev familiar enough with the issues > involved that they ca

Re: [Python-Dev] [python-committers] Reminder: Python 3.5 beta 1 will be tagged tomorrow

2015-05-24 Thread Chris Barker
o folks think about adding one to cmath as well, while we are at it? It should be pretty straightforward -- I could focus what time I have to do that. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 S

Re: [Python-Dev] [python-committers] Reminder: Python 3.5 beta 1 will be tagged tomorrow

2015-05-24 Thread Chris Barker
On Sun, May 24, 2015 at 10:00 AM, Tal Einat wrote: > On Sun, May 24, 2015 at 6:40 PM, Chris Barker > wrote: > > What do folks think about adding one to cmath as well, while we are at > it? > > It should be pretty straightforward -- I could focus what time I have to > d

Re: [Python-Dev] Reminder: 3.5 now has its own branch! "default" branch is now 3.6!

2015-05-24 Thread Chris Angelico
On Mon, May 25, 2015 at 9:49 AM, Larry Hastings wrote: > I've now pushed the 3.5.0 beta 1 release-engineering checkins to > hg.python.org. At the same time I did this, I also created the 3.5 branch. > > Quick FAQ: Additional Q. What does this mean for buildbots? Will they immediately pick up the

[Python-Dev] PEP 485: math.isclose()

2015-05-24 Thread Chris Barker
I don't think I have permissions to comment on the issue,so I'm posting here. If there is a way for me to post to the issue, someone let me know... In the issue (http://bugs.python.org/issue24270) Tal wrote """ I have a question regarding complex values. The code (f

Re: [Python-Dev] PEP 485: math.isclose()

2015-05-24 Thread Chris Barker
e`` if the values *a* and *b* are close to each other and ``False`` otherwise. need a space between "each" and "other" But it all looks good otherwise -- thanks! -Chris On Sun, May 24, 2015 at 9:53 PM, Chris Barker wrote: > I don't think I have permissions to co

<    1   2   3   4   5   6   7   8   9   10   >