Re: [Python-Dev] PEP 484 syntax: NONONONONONONO!

2015-02-01 Thread Chris Angelico
On Sun, Feb 1, 2015 at 9:13 PM, Benjamin wrote: > I much prefer the idea of a 'where' keyword to denote typing, as discussed > http://aroberge.blogspot.com/2015/01/type-hinting-in-python-focus-on.html, > but I think a refinement of their idea would prove even better: > > def retry(callback, timeou

Re: [Python-Dev] Encoding of PyFrameObject members

2015-02-05 Thread Chris Angelico
On Fri, Feb 6, 2015 at 10:27 AM, Francis Giraldeau wrote: > Instead, I access members directly: > char *str = PyUnicode_DATA(frame->f_code->co_filename); > size_t len = PyUnicode_GET_DATA_SIZE(frame->f_code->co_filename); > > Is it safe to assume that unicode objects co_filename and co_name are al

Re: [Python-Dev] subclassing builtin data structures

2015-02-12 Thread Chris Angelico
On Fri, Feb 13, 2015 at 12:46 PM, MRAB wrote: class BaseInt: > ... def __init__(self, value): > ... self._value = value > ... def __add__(self, other): > ... return type(self)(self._value + other) On Fri, Feb 13, 2015 at 11:55 AM, Guido van Rossum wrote: > ... there

Re: [Python-Dev] PEP 370 - per-user scripts directory on Windows

2015-02-15 Thread Chris Angelico
On Sat, Feb 14, 2015 at 11:07 AM, Nick Coghlan wrote: > OTOH, it may be time to reconsider our recommendation to distros as well, > suggesting that for Python 3.5+, we will consider it appropriate to have the > "python" symlink refer to "python3". If *all* distros provide a "python2" symlink, the

Re: [Python-Dev] PEP 370 - per-user scripts directory on Windows

2015-02-16 Thread Chris Angelico
On Mon, Feb 16, 2015 at 10:47 PM, Petr Viktorin wrote: >> If *all* distros provide a "python2" symlink, then the recommendation >> can become "use python if it's 2/3 compatible, or python2/python3 to >> choose", and then it won't hurt to switch python to be python3. >> Are there known distros in w

Re: [Python-Dev] Any volunteers to implement PEP 479?

2015-02-20 Thread Chris Angelico
On Wed, Jan 7, 2015 at 2:48 PM, Guido van Rossum wrote: > There's a proof of concept patch in http://bugs.python.org/issue22906, but > it doesn't have the __future__ import and probably gets other details wrong. > > Reference: > PEP 479 -- Change StopIteration handling inside generators > > -- > -

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-23 Thread Chris Angelico
On Tue, Feb 24, 2015 at 2:44 AM, Guido van Rossum wrote: > I think that's a bit too strong. This has been unquestionably valid, correct > Python -- it was an intentional feature from the start. It may not have > turned out great, but I think that before warning loudly about every > instance of thi

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-23 Thread Chris Angelico
On Tue, Feb 24, 2015 at 3:12 AM, Brett Cannon wrote: > > > On Mon Feb 23 2015 at 10:55:23 AM Chris Angelico wrote: >> >> On Tue, Feb 24, 2015 at 2:44 AM, Guido van Rossum >> wrote: >> > I think that's a bit too strong. This has been unquestionably val

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-24 Thread Chris Angelico
On Tue, Feb 24, 2015 at 7:40 PM, M.-A. Lemburg wrote: > I think the easiest way would be to tweak the error message > output to indicate the real problem. > > At the moment, you get: > open('c:\test.txt') > Traceback (most recent call last): > File "", line 1, in > FileNotFoundError: [Errn

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 6:54 AM, Greg Ewing wrote: > Chris Angelico wrote: >> >> Then he changed the code over to use his >> own file instead of the provided sample, and at the same time, >> switched from using open() to using csv.reader(open()), and moved all >&

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 5:00 PM, Ben Finney wrote: > There is a wider context here, too: semantics of the backslash escape > https://en.wikipedia.org/wiki/Backslash#Usage> commonly include > “backslash followed by a character not otherwise mentioned will produce > that character, verbatim”. > > Pr

Re: [Python-Dev] PEP 488: elimination of PYO files

2015-03-06 Thread Chris Angelico
On Sat, Mar 7, 2015 at 6:09 AM, Benjamin Peterson wrote: > I think it would be preferable deprecate -O and -OO and replace them > with flags like --no-docstrings or --no-asserts. Ideally, "optimization" > levels shouldn't change program semantics. Plenty of C compilers have optimization levels th

Re: [Python-Dev] str.lstrip bug?

2015-03-10 Thread Chris Angelico
On Wed, Mar 11, 2015 at 4:27 AM, lou xiao wrote: > I find a bug in str.lstrip, when i call str.lstrip, i get this result. > > tiny➜ ~ python > Python 2.7.5+ (default, Feb 27 2014, 19:37:08) > [GCC 4.8.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. a='dev

Re: [Python-Dev] Sporadic failures of test_subprocess and test_multiprocessing_spawn

2015-03-28 Thread Chris Angelico
On Sat, Mar 28, 2015 at 8:39 PM, Victor Stinner wrote: > Are you able to reproduce these issues? I'm unable to reproduce them > on Fedora 21. Maybe they are more likely on Debian-like operating > systems? I just tried it on my Debian Wheezy AMD64, not running as root. (The same computer the build

Re: [Python-Dev] Sporadic failures of test_subprocess and test_multiprocessing_spawn

2015-03-28 Thread Chris Angelico
On Sat, Mar 28, 2015 at 9:10 PM, Chris Angelico wrote: > On Sat, Mar 28, 2015 at 8:39 PM, Victor Stinner > wrote: >> Are you able to reproduce these issues? I'm unable to reproduce them >> on Fedora 21. Maybe they are more likely on Debian-like operating >> syste

Re: [Python-Dev] Sporadic failures of test_subprocess and test_multiprocessing_spawn

2015-03-28 Thread Chris Angelico
On Sat, Mar 28, 2015 at 11:50 PM, Victor Stinner wrote: > Good, you are able to reproduce it. The next step is to identify the > sequence of test to reproduce it. How do you run the test suite? Are you > using -j1? I just ran 'make test'. Early in the output are these lines: ./python ./Tools/sc

Re: [Python-Dev] Status on PEP-431 Timezones

2015-04-08 Thread Chris Angelico
On Thu, Apr 9, 2015 at 8:32 AM, Alexander Belopolsky wrote: > A "named offset" is an abbreviation such as UTC, EST, MSK, MSD which (at any > given time) > corresponds to a fixed offset from UTC. That assumes the abbreviations are unique. They're not. Just this morning I had to explain to a new st

Re: [Python-Dev] Status on PEP-431 Timezones

2015-04-15 Thread Chris Angelico
On Thu, Apr 16, 2015 at 1:00 AM, Lennart Regebro wrote: > So because of this, perhaps we actually *should* change the internal > representation to UTC, because that makes the issues I'm fighting with > now so much simpler. (I'm currently trying to get arithmetic to do the > right thing in all case

Re: [Python-Dev] Status on PEP-431 Timezones

2015-04-15 Thread Chris Angelico
On Thu, Apr 16, 2015 at 1:43 AM, Lennart Regebro wrote: > On Wed, Apr 15, 2015 at 11:10 AM, Chris Angelico wrote: >> Bikeshed: Would arithmetic be based on UTC time or Unix time? It'd be >> more logical to describe it as "adding six hours means adding six >> hours

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Chris Angelico
On Tue, Apr 21, 2015 at 9:41 AM, Jack Diederich wrote: > * It is not optional. Please stop saying that. The people promoting it would > prefer that everyone use it. If it is approved it will be optional in the > way that PEP8 is optional. If I'm reading your annotated code it is > certainly /not/

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Chris Angelico
On Tue, Apr 21, 2015 at 10:52 AM, Ben Finney wrote: > Chris Angelico writes: > >> On Tue, Apr 21, 2015 at 9:41 AM, Jack Diederich wrote: >> > * It is not optional. Please stop saying that. The people promoting >> > it would prefer that everyone use it. If it is app

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Tue, Apr 21, 2015 at 6:58 PM, Cory Benfield wrote: > On 21 April 2015 at 01:45, Chris Angelico wrote: >> When you're writing a library, it can be a great help to provide type >> annotations, because every application that uses your library can >> benefit. > >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Tue, Apr 21, 2015 at 7:56 PM, Arnaud Delobelle wrote: > If people constantly get told by their editor / IDE that they are calling > function with the wrong argument types, what are they going to do? They may > start adopting the same approach as in Java / C++ etc... where interfaces > must be

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Wed, Apr 22, 2015 at 12:51 AM, Cory Benfield wrote: > On 21 April 2015 at 15:31, Chris Angelico wrote: >> Granted, there are some >> vague areas - how many functions take a "file-like object", and are >> they all the same? - but between MyPy types and the abst

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-25 Thread Chris Angelico
On Sun, Apr 26, 2015 at 2:01 AM, Ronan Lamy wrote: >>> * PEP484 hints are too high-level. Replacing an 'int' object with a >>> single machine word would be useful, but an 'int' annotation gives no >>> guarantee that it's correct (because Python 3 ints can have arbitrary >>> size and because subcla

Re: [Python-Dev] Unicode literals in Python 2.7

2015-04-29 Thread Chris Angelico
On Thu, Apr 30, 2015 at 11:03 AM, Stephen J. Turnbull wrote: > Note that even if you have a UTF-8 input source, some users are likely > to be surprised because IIRC Python doesn't canonicalize in its > codecs; that is left for higher-level libraries. Linux UTF-8 is > usually NFC normalized, while

Re: [Python-Dev] PYTHONHTTPSVERIFY env var

2015-05-09 Thread Chris Angelico
On Sun, May 10, 2015 at 4:13 AM, M.-A. Lemburg wrote: > By providing a way to intentionally switch off the new default, > we do make people aware of the risks and that's good enough, > while still maintaining the contract people rightly expect of > patch level releases of Python. Just as long as

Re: [Python-Dev] How shall we conduct the Python 3.5 beta and rc periods? (Please vote!)

2015-05-12 Thread Chris Angelico
On Wed, May 13, 2015 at 3:04 AM, Larry Hastings wrote: > Workflow 1 > == > > When I ship beta 1, we create the 3.5 branch. trunk become 3.6. > > When I ship rc 1, the 3.5 branch becomes 3.5.1. I maintain a publically > visible repo on bitbucket for 3.5.0, and we use bitbucket "pull reque

Re: [Python-Dev] Tracker reviews look like spam

2015-05-12 Thread Chris Angelico
On Wed, May 13, 2015 at 8:15 AM, David Wilson wrote: > SPF only covers the envelope sender, so it should be possible to set > that to something that validates with SPF, keep the RFC822 From: header > as it is, and maybe(?) include a separate Sender: header matching the > envelope address. As Came

Re: [Python-Dev] [Python-checkins] peps: Apply Chris's changes, including an acceptance mark

2015-05-17 Thread Chris Angelico
On Mon, May 18, 2015 at 1:04 AM, Yury Selivanov wrote: > Chris, > > Could you please add a link to the email where the PEP was accepted? Sure. A Resolution: header is the right way to do this? Done. ChrisA ___ Python-Dev mailing list Python-Dev@python.

Re: [Python-Dev] PEP 559 - built-in noop()

2017-09-10 Thread Chris Angelico
On Mon, Sep 11, 2017 at 7:29 AM, Koos Zevenhoven wrote: > On Sun, Sep 10, 2017 at 8:21 PM, Barry Warsaw wrote: >> >> On Sep 9, 2017, at 15:12, Guido van Rossum wrote: >> > >> > I can't tell whether this was meant seriously, but I don't think it's >> > worth it. People can easily write their own

Re: [Python-Dev] PEP 559 - built-in noop()

2017-09-10 Thread Chris Angelico
On Mon, Sep 11, 2017 at 11:03 AM, Barry Warsaw wrote: > On Sep 10, 2017, at 14:39, Chris Angelico wrote: >> >> As a language change, definitely not. But I like this idea for >> PYTHONBREAKPOINT. You set it to the name of a function, or to "pass" >> if you wa

Re: [Python-Dev] Investigating time for `import requests`

2017-10-08 Thread Chris Angelico
On Sun, Oct 8, 2017 at 7:02 PM, David Cournapeau wrote: > It is certainly true that for a CLI tool that actually makes any network > I/O, especially SSL, import times will quickly be negligible. It becomes > tricky for complex tools, because of error management. For example, a common > pattern I h

Re: [Python-Dev] PEP 564: Add new time functions with nanosecond resolution

2017-10-22 Thread Chris Angelico
On Mon, Oct 23, 2017 at 2:06 AM, Wes Turner wrote: > What about bus latency (and variance)? I'm currently in Los Angeles. Bus latency is measured in minutes, and may easily exceed sixty of them. :| Seriously though: For applications requiring accurate representation of relativistic effects, the

Re: [Python-Dev] Guarantee ordered dict literals in v3.7?

2017-11-06 Thread Chris Angelico
On Mon, Nov 6, 2017 at 9:36 PM, Stefan Krah wrote: > On Mon, Nov 06, 2017 at 12:18:17PM +0200, Paul Sokolovsky wrote: >> MicroPython hashmap implementation is effectively O(n) (average and >> worst case) due to the algorithm parameters chosen (like the load factor >> of 1). Of course, parameters c

Re: [Python-Dev] The current dict is not an "OrderedDict"

2017-11-07 Thread Chris Angelico
On Wed, Nov 8, 2017 at 1:32 AM, Antoine Pitrou wrote: > On Wed, 8 Nov 2017 00:01:04 +1000 > Nick Coghlan wrote: > >> On 7 November 2017 at 23:48, Stefan Krah wrote: >> > >> > >> > This is just a reminder that the current dict is not an "OrderedDict": >> > >> from collections import OrderedD

Re: [Python-Dev] PEP 565: Show DeprecationWarning in __main__

2017-11-13 Thread Chris Angelico
On Mon, Nov 13, 2017 at 9:46 PM, Antoine Pitrou wrote: > On Sun, 12 Nov 2017 19:48:28 -0800 > Nathaniel Smith wrote: >> On Sun, Nov 12, 2017 at 1:24 AM, Nick Coghlan wrote: >> > This change will lead to DeprecationWarning being displayed by default for: >> > >> > * code executed directly at the

Re: [Python-Dev] Tricky way of of creating a generator via a comprehension expression

2017-11-22 Thread Chris Angelico
On Thu, Nov 23, 2017 at 3:36 PM, Greg Ewing wrote: > Paul Moore wrote: >> >> 3. List comprehensions are the same as list(the equivalent generator >> expression). > > > I don't think that's ever been quite true -- there have > always been odd cases such as what happens if you > raise StopIteration

Re: [Python-Dev] Tricky way of of creating a generator via a comprehension expression

2017-11-23 Thread Chris Angelico
On Fri, Nov 24, 2017 at 1:21 AM, Paul Moore wrote: > On 23 November 2017 at 13:04, Ivan Levkivskyi wrote: >> Let us forget for a moment about other problems and focus on this one: list >> comprehension is currently not equivalent to a for-loop. >> There are two options: >> - Fix this, i.e. make c

Re: [Python-Dev] Using async/await in place of yield expression

2017-11-26 Thread Chris Angelico
On Mon, Nov 27, 2017 at 2:20 PM, David Mertz wrote: > Changing subject line because this is way off to the side. Guido and > Nathaniel point out that you can do everything yield expressions do with > async/await *without* an explicit event loop. While I know that is true, it > feels like the bes

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

2017-11-30 Thread Chris Angelico
On Fri, Dec 1, 2017 at 5:45 AM, Tres Seaver wrote: >> I would *not* add any spelling for an explicit bare-except equivalent. >> You would have to write: >> >> val = name.strip()[4:].upper() except Exception as -1 > > > Wouldn't that really need to be this instead, for a true 'except:' > equival

Re: [Python-Dev] PEP 540: Add a new UTF-8 mode (v2)

2017-12-05 Thread Chris Angelico
On Wed, Dec 6, 2017 at 4:46 PM, Nick Coghlan wrote: > Something I've just noticed that needs to be clarified: on Linux, "C" > locale and "POSIX" locale are aliases, but this isn't true in general > (e.g. it's not the case on *BSD systems, including Mac OS X). For those of us with little to no BSD

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

2017-12-12 Thread Chris Angelico
On Tue, Dec 12, 2017 at 7:39 PM, Michel Desmoulin wrote: > > > Le 29/11/2017 à 19:02, Barry Warsaw a écrit : >> On Nov 29, 2017, at 12:40, David Mertz wrote: >> >>> I think some syntax could be possible to only "catch" some exceptions and >>> let others propagate. Maybe: >>> >>>val = name.s

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

2017-12-12 Thread Chris Angelico
On Wed, Dec 13, 2017 at 6:03 AM, Guido van Rossum wrote: > And I'll never approve syntax to make it easier to just ignore all > exceptions without looking at them. Well, I certainly wouldn't advocate "except Exception: -1", but the syntax is the same as "except KeyError: -1" which is less unreaso

Re: [Python-Dev] [python/peps] PEP 567 review and copyedits (#503)

2017-12-12 Thread Chris Angelico
Redirecting comments from the PR to the ML. Everything that was tightly bound to the PR has been dropped. On Wed, Dec 13, 2017 at 12:15 PM, Yury Selivanov wrote: > Most of your questions should be asked on python-dev. I'll answer them here, > but if you have any follow-ups, please raise the on t

Re: [Python-Dev] Guarantee ordered dict literals in v3.7?

2017-12-18 Thread Chris Angelico
On Tue, Dec 19, 2017 at 6:09 PM, Steven D'Aprano wrote: > I completely agree. We might argue that it was a mistake to sort dicts > in the first place, or at least a mistake to *always* sort them without > allowing the caller to provide a sort key. But what's done is done: the > fact that dicts are

Re: [Python-Dev] [ssl] The weird case of IDNA

2017-12-31 Thread Chris Angelico
On Mon, Jan 1, 2018 at 12:39 PM, Steven D'Aprano wrote: > On Sun, Dec 31, 2017 at 09:07:01AM -0800, Nathaniel Smith wrote: > >> This is another reason why we ought to let users do their own IDNA handling >> if they want... > > I expect that letting users do their own IDNA handling will correspond

Re: [Python-Dev] Why wont duplicate methods be flagged as error (syntax or anything suitable error)

2018-01-14 Thread Chris Angelico
On Sun, Jan 14, 2018 at 7:10 PM, joannah nanjekye wrote: > Hello, > > Apparently when you implement two methods with the same name: > > def sub(x, y): > print(x -y) > > def sub(x, y): > print(x -y) > > Even with type hints. > > def sub(x: int, y:int) -> int: > return x - y > > def su

Re: [Python-Dev] Guido's Python 1.0.0 Announcement from 27 Jan 1994

2018-01-27 Thread Chris Angelico
On Sun, Jan 28, 2018 at 3:58 AM, Senthil Kumaran wrote: > Someone in HackerNews shared the Guido's Python 1.0.0 announcement from 27 > Jan 1994. That is, on this day, 20 years ago. > > https://groups.google.com/forum/?hl=en#!original/comp.lang.misc/_QUzdEGFwCo/KIFdu0-Dv7sJ > > It is very entertain

Re: [Python-Dev] How is the GitHub workflow working for people?

2018-02-21 Thread Chris Angelico
On Thu, Feb 22, 2018 at 8:38 AM, Guido van Rossum wrote: > On Wed, Feb 21, 2018 at 1:28 PM, Bernát Gábor > wrote: >> >> Any reason in particular for not using github issues (or blockers in >> achieving this)? > > > Many core devs did not want to change their workflow, and Brett did not want > to

Re: [Python-Dev] The `for y in [x]` idiom in comprehensions

2018-02-25 Thread Chris Angelico
On Sun, Feb 25, 2018 at 11:02 PM, Nikolaus Rath wrote: > On Feb 22 2018, Serhiy Storchaka wrote: >> 1. Inner generator expression: >> >> result = [y + g(y) for y in (f(x) for x in range(10))] >> > [...] >> >> And maybe there are other ways. > > I think the syntax recently brough up by Nick is

Re: [Python-Dev] The `for y in [x]` idiom in comprehensions

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 12:11 AM, Nikolaus Rath wrote: > On Feb 25 2018, Chris Angelico wrote: >> On Sun, Feb 25, 2018 at 11:02 PM, Nikolaus Rath wrote: >>> On Feb 22 2018, Serhiy Storchaka wrote: >>>> 1. Inner generator expression: >>>> >>&

Re: [Python-Dev] The `for y in [x]` idiom in comprehensions

2018-02-26 Thread Chris Angelico
On Mon, Feb 26, 2018 at 8:00 PM, Nick Coghlan wrote: > On 26 February 2018 at 01:08, Chris Angelico wrote: >> >> Speaking as a C programmer who's quite happy to write code like "while >> ((var = func()) != sentinel)", I wouldn't object to this coming up i

[Python-Dev] Code stability and a big thank you

2018-02-26 Thread Chris Angelico
As part of the discussions on local name binding, I dug up a patch that I sent to python-ideas back in June 2015. That's two and a half years ago, and was based on CPython 3.5. Here's what happened when I attempted to apply it to the current master branch (3.8): $ patch <~/Downloads/scope_hack.pat

Re: [Python-Dev] PEP 574 -- Pickle protocol 5 with out-of-band data

2018-03-29 Thread Chris Angelico
On Thu, Mar 29, 2018 at 7:18 PM, Nathaniel Smith wrote: > Another example is the multiprocessing module: it's very safe to > assume that the parent and the child are using the same interpreter > :-). There's no fundamental reason you shouldn't be able to send > bytecode between them. You put a sm

Re: [Python-Dev] PEP 574 -- Pickle protocol 5 with out-of-band data

2018-03-29 Thread Chris Angelico
On Thu, Mar 29, 2018 at 7:56 PM, Paul Moore wrote: > On 29 March 2018 at 09:49, Chris Angelico wrote: >> On Thu, Mar 29, 2018 at 7:18 PM, Nathaniel Smith wrote: >>> Another example is the multiprocessing module: it's very safe to >>> assume that the parent

Re: [Python-Dev] Subtle difference between f-strings and str.format()

2018-03-29 Thread Chris Angelico
On Thu, Mar 29, 2018 at 11:28 PM, Steven D'Aprano wrote: > On Wed, Mar 28, 2018 at 06:27:19PM +0300, Serhiy Storchaka wrote: > >> The optimizer already changes >> semantic. Non-optimized "if a and True:" would call bool(a) twice, but >> optimized code calls it only once. > > I don't understand thi

Re: [Python-Dev] Subtle difference between f-strings and str.format()

2018-03-29 Thread Chris Angelico
On Fri, Mar 30, 2018 at 1:08 AM, Chris Angelico wrote: > On Thu, Mar 29, 2018 at 11:28 PM, Steven D'Aprano wrote: >> On Wed, Mar 28, 2018 at 06:27:19PM +0300, Serhiy Storchaka wrote: >> >>> The optimizer already changes >>> semantic. Non-optimized "if

Re: [Python-Dev] Python version numbers

2018-04-03 Thread Chris Angelico
On Tue, Apr 3, 2018 at 10:51 PM, Paul G wrote: > Breaking this off from the pickle thread because it seems unrelated: > > On 04/02/2018 06:57 PM, Lukasz Langa wrote: >> I think we need to get past thinking about "Python 2" vs. "Python 3". This >> frame of mind creates space for another mythical r

[Python-Dev] PEP 572: Assignment Expressions

2018-04-17 Thread Chris Angelico
572 Title: Assignment Expressions Author: 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 Abstract This is a proposal for creating a way to

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

2018-04-17 Thread Chris Angelico
On Tue, Apr 17, 2018 at 6:26 PM, Chris Jerdonek wrote: > On Tue, Apr 17, 2018 at 12:46 AM, Chris Angelico wrote: >> >> Having survived four rounds in the boxing ring at python-ideas, PEP >> 572 is now ready to enter the arena of python-dev. I'll let the >> pro

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

2018-04-17 Thread Chris Angelico
On Tue, Apr 17, 2018 at 10:17 PM, Nick Coghlan wrote: > Initially I thought the problem was specific to tuple unpacking > syntax, but attempting to explain why subscript assignment and > attribute assignments were OK made me realise that they're actually > even worse off (since they can execute ar

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

2018-04-17 Thread Chris Angelico
On Wed, Apr 18, 2018 at 5:28 AM, Tim Peters wrote: > I'll channel that Guido would be happiest if this rule were followed: > > Given an assignment statement using "=", the meaning is the same if > "=" is replaced with ":=". That's broadly the intention. At the moment, there are two exceptions: 1

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

2018-04-17 Thread Chris Angelico
On Wed, Apr 18, 2018 at 7:53 AM, Terry Reedy wrote: > On 4/17/2018 3:46 AM, Chris Angelico wrote: > >> Abstract >> >> >> This is a proposal for creating a way to assign to names within an >> expression. > > > I started at -something as t

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

2018-04-17 Thread Chris Angelico
On Wed, Apr 18, 2018 at 11:20 AM, Steven D'Aprano wrote: > On Wed, Apr 18, 2018 at 10:13:58AM +1000, Chris Angelico wrote: > > [regarding comprehensions] > >> The changes here are only to edge and corner cases, other than as they >> specifically relate to assign

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

2018-04-18 Thread Chris Angelico
On Wed, Apr 18, 2018 at 11:58 PM, Guido van Rossum wrote: > I can't tell from this what the PEP actually says should happen in that > example. When I first saw it I thought "Gaah! What a horrible piece of > code." But it works today, and people's code *will* break if we change its > meaning. > > H

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

2018-04-18 Thread Chris Angelico
On Thu, Apr 19, 2018 at 2:18 AM, Guido van Rossum wrote: > On Wed, Apr 18, 2018 at 7:35 AM, Chris Angelico wrote: >> >> On Wed, Apr 18, 2018 at 11:58 PM, Guido van Rossum >> wrote: >> > I can't tell from this what the PEP actually says should happen in that

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

2018-04-18 Thread Chris Angelico
On Thu, Apr 19, 2018 at 6:26 AM, Barry Warsaw wrote: > On Apr 18, 2018, at 11:17, Chris Angelico wrote: > >> At the moment, it isn't aware of 'del’. > > I don’t know if it’s relevant to the current discussion, but don’t forget > about implicit dels: >

[Python-Dev] PEP 572: Now with 25% less reference implementation!

2018-04-19 Thread Chris Angelico
ll need to change, if it tried to use the same name in multiple scopes, or tried to use ancient Python 2 semantics with a yield expression in the outermost iterable. I'm pretty much ready for pronouncement. https://www.python.org/dev/peps/pep-0572/ ChrisA PEP: 572 Title: Assignment Express

Re: [Python-Dev] PEP 572: Now with 25% less reference implementation!

2018-04-19 Thread Chris Angelico
On Fri, Apr 20, 2018 at 2:45 PM, Dmitry Malinovsky wrote: > Hello Chris, and thank you for working on this PEP! > > What do you think about using variable type hints with this syntax? > I tried to search through python-dev and couldn't find a single post > discussing that question. > If I missed i

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

2018-04-19 Thread Chris Angelico
On Fri, Apr 20, 2018 at 1:30 PM, Stephen J. Turnbull wrote: > Christoph Groth writes: > > > Wouldn't it be a pity not to liberate assignments from their boring > > statement existence? > > Maybe not. While it would be nice to solve the loop-and-a-half > "problem" and the loop variable initializ

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

2018-04-19 Thread Chris Angelico
On Fri, Apr 20, 2018 at 4:32 PM, Robert Smallshire wrote: > If you restrict the idea to 'if' and 'while', Why not render this using the > existing 'as' form for binding names, already used with 'except' and 'with': > > while learner.get(static_hint) as points: > learner.feed(f(points))

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

2018-04-20 Thread Chris Angelico
On Fri, Apr 20, 2018 at 6:32 PM, Paul Moore wrote: >> def read_document(file): >> doc = "" >> while (token := file.get_next_token()) != "END": >> doc += token >> return doc >> >> The loop condition is "while the token is not END", or "while >> get_next_token() doesn't return EN

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

2018-04-20 Thread Chris Angelico
On Fri, Apr 20, 2018 at 10:51 PM, Paul Moore wrote: > 2. I hadn't really thought of the PEP in those terms. Now that you've > mentioned it, "Python has never before had syntax that assigns names > from within an expression" is quite a significant change, and one the > PEP needs to examine the impl

Re: [Python-Dev] PEP 572: Now with 25% less reference implementation!

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 1:50 AM, Guido van Rossum wrote: > Maybe annotations should get a brief mention in the Rejected Ideas section, > with your explanation here added. (And maybe my response.) Good idea. Actually, since it's a syntactic difference, I've promoted it to the "Differences" section

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

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 2:17 AM, Christoph Groth wrote: > Chris Barker - NOAA Federal wrote: > >> > Personally, I even slightly prefer >> > >> > a := 3 >> > >> > to the commonplace >> > >> > a = 3 >> > because it visually expresses the asymmetry of the operation. >> >> Careful here! That’s a fine

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

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 2:50 AM, Mike Miller wrote: > > On 2018-04-19 23:52, Chris Angelico wrote: >> >> And are limited to conditions that check the truthiness/falsiness of >> the value you care about. So that works for re.match, but not for >> anything that might

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

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 6:04 AM, David Mertz wrote: > It's horrors like this: > > g(items[idx] := idx := f()) > > That make me maybe +0 if the PEP only allowed simple name targets, but > decisively -1 for any assignment target in the current PEP. But that's my point: you shouldn't need to wri

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

2018-04-20 Thread Chris Angelico
On Sat, Apr 21, 2018 at 6:59 AM, Guido van Rossum wrote: > Does the PEP currently propose to *allow* that horrible example? I thought > Tim Peters successfully pleaded to *only* allow a single "NAME := ". > You don't have to implement this restriction -- we know it's possible to > implement, and i

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 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 - x_base, and g, which " or >> "if diff, which we def

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

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