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

2017-02-18 Thread Eric V. Smith
On 2/18/2017 2:25 AM, Steven D'Aprano wrote: On Fri, Feb 17, 2017 at 11:37:04AM -0500, Mark E. Haase wrote: Python has two string formatting mini-languages. Four. % string formatting, .format method, f-strings, string.Template strings. But who's counting? :-) Technical correctness is the

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-18 Thread Eric V. Smith
On 8/18/2016 3:15 PM, Terry Reedy wrote: On 8/18/2016 12:50 PM, Steve Dower wrote: I find it hard to not read f'{x.partition(' + ')[0]}' as string concatenation. and it will certainly be easier for highlighters to handle (assuming they're doing anything more complicated than simply displaying

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Eric V. Smith
On 8/18/2016 11:05 AM, Philipp A. wrote: Hi, I originially posted this via google groups, which didn’t make it through to the list proper, sorry! Read it here please: https://groups.google.com/forum/#!topic/python-ideas/V1U6DGL5J1s Hi, Philipp. I'm including your original proposal here, so

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Eric V. Smith
On 8/19/2016 1:16 AM, Terry Reedy wrote: On 8/18/2016 8:27 PM, Eric V. Smith wrote: So something that parses or scans a Python file and currently understands u, b, and r to be string prefixes, just needs to add f to the prefixes it uses, and it can now at least understand f-strings (and fr

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-20 Thread Eric V. Smith
On 8/19/2016 2:57 PM, Guido van Rossum wrote: I don't think we should take action now. Would it make sense, as a precaution, to declare the PEP provisional for one release? Then we can develop a sense of whether the current approach causes real problems. We could also emit some kind of warning

Re: [Python-ideas] add __contains__ into the "type" object

2017-02-28 Thread Eric V. Smith
On 2/28/2017 6:35 PM, Jelle Zijlstra wrote: 2017-02-28 15:12 GMT-08:00 Steven D'Aprano : On Wed, Mar 01, 2017 at 07:02:23AM +0800, 语言破碎处 wrote: where we use types? almost: isinstance(obj, T); # issubclass(S, T); Note that TYPE is SET; What does that

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Eric V. Smith
> On Mar 1, 2017, at 9:35 AM, Paul Moore wrote: > >> On 1 March 2017 at 13:50, Steven D'Aprano wrote: >> It is possible that we could come up with a pretty-printing protocol, >> but that wouldn't be a trivial job. > > I'd be inclined to do this via

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-29 Thread Eric V. Smith
On 8/29/2016 5:40 PM, Steve Dower wrote: On 29Aug2016 1433, Eric V. Smith wrote: On 8/29/2016 5:26 PM, Ethan Furman wrote: Update the PEP, then it's a bugfix. ;) Heh. I guess that's true. But it's sort of a big change, so shipping beta 1 with the code not agreeing with the PEP rubs me

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-29 Thread Eric V. Smith
On 8/23/2016 8:18 AM, Nick Coghlan wrote: On 21 August 2016 at 03:32, Eric V. Smith <e...@trueblade.com> wrote: If anything, I'd make it an error to have any backslashes inside the brackets of an f-string for 3.6. We could always remove this restriction at a later date. +1 for this if y

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-29 Thread Eric V. Smith
Oops, I meant beta 1 where I said alpha 1. Eric. On 8/29/2016 5:12 PM, Eric V. Smith wrote: On 8/23/2016 8:18 AM, Nick Coghlan wrote: On 21 August 2016 at 03:32, Eric V. Smith <e...@trueblade.com> wrote: If anything, I'd make it an error to have any backslashes inside the brackets o

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

2016-08-31 Thread Eric V. Smith
On 08/31/2016 01:07 PM, MRAB wrote: > On 2016-08-31 17:19, Guido van Rossum wrote: >> On Wed, Aug 31, 2016 at 5:21 AM, Nick Coghlan wrote: >>> "h" would be a decent choice - it's not only a continuation of the >>> e/f/g pattern, it's also very commonly used as a command line

[Python-ideas] Alternative to PEP 532: delayed evaluation of expressions

2016-11-06 Thread Eric V. Smith
Creating a new thread, instead of hijacking the PEP 532 discussion. From PEP 532: > Abstract > > > Inspired by PEP 335, PEP 505, PEP 531, and the related discussions, this PEP > proposes the addition of a new protocol-driven circuit breaking operator to > Python that allows the left

Re: [Python-ideas] Alternative to PEP 532: delayed evaluation of expressions

2016-11-06 Thread Eric V. Smith
ated expressions that can be evaluated at a different point? -- Eric. > On Nov 6, 2016, at 8:06 AM, Eric V. Smith <e...@trueblade.com> wrote: > > Creating a new thread, instead of hijacking the PEP 532 discussion. > > From PEP 532: > > > Abstract > > >

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-29 Thread Eric V. Smith
On 11/29/2016 1:33 PM, Brett Cannon wrote: On Tue, 29 Nov 2016 at 06:49 Nick Coghlan > wrote: On 29 November 2016 at 20:54, Tomas Orsava > wrote: > With a metapath hook, .missing.py files

Re: [Python-ideas] Add pathlib.Path.write_json and pathlib.Path.read_json

2017-03-27 Thread Eric V. Smith
On 3/27/17 10:40 AM, Ram Rachum wrote: Another idea: Maybe make json.load and json.dump support Path objects? json.dump requires open file objects, not strings or Paths representing filenames. But does this not already do what you want: Path('foo.json').write_text(json.dumps(obj)) ? Eric.

Re: [Python-ideas] Proposal: making __str__ count in time's class

2017-04-09 Thread Eric V. Smith
On 3/8/2017 11:01 AM, Francesco Franchina wrote: Hello everyone, I'm shortly writing to you about a reflection I lately made upon the current functioning of __str__ for the time's class. Before expressing my thought and proposal, I want to make sure we all agree on a simple and clear fact:

Re: [Python-ideas] dict(default=int)

2017-03-08 Thread Eric V. Smith
On 3/8/2017 5:43 PM, Chris Angelico wrote: On Thu, Mar 9, 2017 at 9:39 AM, Brice PARENT wrote: But a possible workaround, is if we used the first positional argument of dict() as the default value. As right now it doesn't accept positional arguments (or at least if they are

Re: [Python-ideas] Data Classes (was: Re: JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects))

2017-07-12 Thread Eric V. Smith
> On Jul 12, 2017, at 9:02 PM, Gregory P. Smith <g...@krypto.org> wrote: > > >> On Thu, May 18, 2017 at 6:38 PM Eric V. Smith <e...@trueblade.com> wrote: >> On 5/18/17 2:26 PM, Sven R. Kunze wrote: >> > On 17.05.2017 23:29, Ivan Levkivskyi wrote

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-17 Thread Eric V. Smith
On 5/16/17 5:04 PM, Guido van Rossum wrote: Stephen, What features of attrs specifically solve your use cases? Also not Stephan! As others have said, it's the "tupleness" of namedtuple that has bitten me. Also, option mutability is key for my use cases. One use case that attrs satisfies

[Python-ideas] Data Classes (was: Re: JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects))

2017-05-18 Thread Eric V. Smith
On 5/18/17 2:26 PM, Sven R. Kunze wrote: On 17.05.2017 23:29, Ivan Levkivskyi wrote: the idea is to write it into a PEP and consider API/corner cases/implementation/etc. Who's writing it? Guido, Hynek, and I met today. I'm writing up our notes, and hopefully that will eventually become a

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-18 Thread Eric V. Smith
On 5/18/17 2:26 PM, Sven R. Kunze wrote: On 17.05.2017 23:29, Ivan Levkivskyi wrote: On 17 May 2017 at 20:09, Sven R. Kunze > wrote: class Foo(dictlike, tuplelike, simpleobject): attribute1: User attribute2: Blog attribute3:

Re: [Python-ideas] Why not picoseconds?

2017-10-15 Thread Eric V. Smith
On 10/15/2017 3:13 PM, Stephan Houben wrote: Hi all, I propose multiples of the Planck time, 5.39 × 10 ^−44 s. Unlikely computers can be more accurate than that anytime soon. On a more serious note, I am not sure what problem was solved by moving from double to a fixed-precision format. I

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

2017-11-29 Thread Eric V. Smith
> On Nov 29, 2017, at 12:40 PM, David Mertz wrote: > > I like much of the thinking in Random's approach. But I still think None > isn't quite special enough to warrant it's own syntax. > > However, his '(or None: name.strip()[4:].upper())' makes me realize that what > is

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 10:01 AM, Paul Moore wrote: On 9 May 2018 at 14:49, Eric V. Smith <e...@trueblade.com> wrote: I would object to changing the format machinery. Any format spec should be interpreted by some object's __format__ method. Agreed. In theory this is a nice idea, but the way form

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 9:28 AM, Chris Angelico wrote: On Wed, May 9, 2018 at 11:06 PM, Steven D'Aprano wrote: On Wed, May 09, 2018 at 09:39:08AM -0300, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors:

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 8:39 AM, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors: John, Mary, Estela' In this case the join can be made in the format yes, but this proposal would be very useful when the info to format comes

Re: [Python-ideas] Have a "j" format option for lists

2018-05-10 Thread Eric V. Smith
On 5/10/18 7:02 AM, Rhodri James wrote: If so, does anything in that string need escaping, like say braces or other "j"s? I'm not sure if format specifiers currently allow arbitrary text (I don't think they do, but I'm not sure), which might make this a more serious undertaking than it first

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

2018-05-11 Thread Eric V. Smith
On 5/11/18 5:12 PM, Angus Hollands wrote: *Readability:* A smaller point is that I don't feel that ":=" is very readable. If we had to use an operator, I think $= is better, but me reasoning for this is weak. I think it derives from my observation that ":=" is slow to distinguish from "=". :=

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

2018-05-13 Thread Eric V. Smith
On 5/13/18 1:05 AM, Chris Angelico wrote: On Sun, May 13, 2018 at 2:58 PM, Cameron Simpson wrote: On 13May2018 14:23, Chris Angelico wrote: On Sun, May 13, 2018 at 2:05 PM, Cameron Simpson wrote: Could someone point me to a post which

Re: [Python-ideas] Have a "j" format option for lists

2018-05-10 Thread Eric V. Smith
On 5/10/18 12:28 PM, Facundo Batista wrote: 2018-05-10 10:34 GMT-03:00 Chris Angelico : Ideally, it will handle *any* iterable. If it's to handle arbitrary iterables, it can't be the normal style of "take this string, pass it to the object's __format__ method, and let it

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

2018-05-08 Thread Eric V. Smith
On 5/8/2018 3:37 AM, Eloi Gaudry wrote: On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: My question is how is this different to running with -O which leaves the assert statement out of the bytecode and so you avoid any run- time cost of the statement entirely? Not so much different,

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

2018-05-08 Thread Eric V. Smith
On 5/8/2018 9:50 AM, Eloi Gaudry wrote: On Tue, 2018-05-08 at 09:35 -0400, Eric V. Smith wrote: On 5/8/2018 3:37 AM, Eloi Gaudry wrote: On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: My question is how is this different to running with -O which leaves the assert statement out

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

2018-05-16 Thread Eric V. Smith
On 5/16/18 4:47 AM, Eric V. Smith wrote: On 5/16/18 4:13 AM, Paul Moore wrote: Can you give a worked example of how this would help if we wanted to introduce a new keyword? For example, if we intended to make "where" a keyword, what would numpy and its users need to do to cont

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

2018-05-16 Thread Eric V. Smith
On 5/16/18 4:13 AM, Paul Moore wrote: On 16 May 2018 at 01:41, Steven D'Aprano wrote: Inspired by Alex Brault's post: https://mail.python.org/pipermail/python-ideas/2018-May/050750.html I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash

Re: [Python-ideas] Escaped braces in format specifiers

2018-05-19 Thread Eric V. Smith
On 5/19/2018 1:56 AM, Ken Kundert wrote: On Tue, May 15, 2018 at 04:23:26PM -0400, Eric V. Smith wrote: I'm busy at the sprints, so I don't have a lot of time to think about this. However, let me just say that recursive format specs are supported, to a depth of 1. width=10 f'{"test&qu

Re: [Python-ideas] Escaped braces in format specifiers

2018-05-17 Thread Eric V. Smith
> On May 17, 2018, at 9:56 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > >> On 15 May 2018 at 16:23, Eric V. Smith <e...@trueblade.com> wrote: >> I'm busy at the sprints, so I don't have a lot of time to think about this. >> >> However, let me just say

Re: [Python-ideas] Escaped braces in format specifiers

2018-05-15 Thread Eric V. Smith
I'm busy at the sprints, so I don't have a lot of time to think about this. However, let me just say that recursive format specs are supported, to a depth of 1. >>> width=10 >>> f'{"test":{width}}' 'test ' So first the string is basically expanded to: f'{"test":10}' Then the string is

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

2018-05-17 Thread Eric V. Smith
[Resending due to Google Groups getting involved and giving me an error] On 5/17/2018 2:41 PM, Neil Girdhar wrote: My preference is to do nothing.  If you end up making "where" a keyword in Python 3.8, numpy will probably: * rename their where function to "where_" in 3.8 * add a where_ alias

Re: [Python-ideas] Python Decorator Improvement Idea

2018-06-16 Thread Eric V. Smith
On 6/16/2018 8:22 PM, Michael Selik wrote: The idea of having a dunder to introspect the bound variable name has been discussed before. You can find the past discussions in the mailing list archive. If I recall correctly, there were very few use cases beyond namedtuple. With dataclasses

Re: [Python-ideas] Dataclasses, keyword args, and inheritance

2018-01-25 Thread Eric V. Smith
I'm not completely opposed to this feature. But there are some cases to consider. Here's the first one that occurs to me: note that due to the way dataclasses work, it would need to be used everywhere down an inheritance hierarchy. That is, if an intermediate base class required it, all class

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Eric V. Smith
On 1/28/2018 6:51 AM, Nick Coghlan wrote: On 28 January 2018 at 19:30, Stephan Houben wrote: Hi David, Perhaps the "n" locale-dependent number formatting specifier should accept a , to have locale-appropriate formatting of thousand separators? f"{x:,n}" would Do The

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-31 Thread Eric V. Smith
On 1/29/2018 2:13 AM, Nick Coghlan wrote: On 29 January 2018 at 11:48, Nathaniel Smith wrote: On Sun, Jan 28, 2018 at 5:31 PM, David Mertz wrote: I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. But it's still much less general than

Re: [Python-ideas] Format mini-language for lakh and crore

2018-02-01 Thread Eric V. Smith
On 2/1/2018 12:05 AM, David Mertz wrote: So overall I do like Nick's approach better than my initial suggestion or Eric's one that is similar to mine. Oops, I'd forgotten that you (David) had proposed a single character in your original email. I'm not trying to claim the idea! The important

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-28 Thread Eric V. Smith
On 7/28/2018 7:02 AM, Miro Hrončok wrote: On 28.7.2018 07:27, Tim Peters wrote: In any case, since OrderedDict seems to be viewed as a legacy feature now, making any change to it is an odd idea on the face of it. As far as I understood the discussions on python-dev, it is not viewed as

Re: [Python-ideas] Consider adding an iterable option to dataclass

2018-08-10 Thread Eric V. Smith
On 8/10/2018 7:01 PM, Neil Girdhar wrote: It would be nice if dataclasses (https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) had an option to make them a sequence.  This would make dataclass(frozen=True, order=True, sequence=True) an optionally-typed version of

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

2018-07-19 Thread Eric V. Smith
supplied a count (see my example below). You can't change its behavior. Eric On Thu, Jul 19, 2018 at 11:17 AM, Eric V. Smith <mailto:e...@trueblade.com>> wrote: On 7/19/2018 10:01 AM, Calvin Spealman wrote: As an alternative suggestion: What if the count

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

2018-07-19 Thread Eric V. Smith
On 7/19/2018 10:01 AM, Calvin Spealman wrote: As an alternative suggestion: What if the count parameter to str.replace() counted from the right with negative values? That would be consistent with other things like indexing and slicing. We couldn't make this change because negative values

Re: [Python-ideas] Add recordlcass to collections module

2018-09-04 Thread Eric V. Smith
On 9/4/2018 3:03 PM, Chris Barker via Python-ideas wrote: Chiming in here: dataclasses was just added to the stdlib. I understand that record class is not the same thing, but the use cases do overlap a great deal. So I think the cord goal for anyone that wants to see this in the stdlib is

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-29 Thread Eric V. Smith
On 8/29/2018 6:39 PM, Eric Fahlgren wrote: On Wed, Aug 29, 2018 at 3:07 PM Marko Ristin-Kaufmann mailto:marko.ris...@gmail.com>> wrote: Could you please elaborate a bit? I don't see how the annotations would make the contracts invoked on inheritance. Consider this simple case:

Re: [Python-ideas] Add new `Symbol` type

2018-07-09 Thread Eric V. Smith
On 7/9/2018 5:01 PM, Brett Cannon wrote: On Fri, 6 Jul 2018 at 09:24 Eric V. Smith <mailto:e...@trueblade.com>> wrote: On 7/6/2018 11:20 AM, Flavio Curella wrote: > I think this thread can be resolved as 'used unittest.mock.sentinel'. It > doesn't have 'g

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Eric V. Smith
On 7/6/2018 11:20 AM, Flavio Curella wrote: I think this thread can be resolved as 'used unittest.mock.sentinel'. It doesn't have 'global sentinels', but I'm not convinced they are actually necessary, since `mock.sentinel` objects with the same name compare as equal. Thanks to Nathaniel, I now

Re: [Python-ideas] Move optional data out of pyc files

2018-04-10 Thread Eric V. Smith
>> 3. Annotations. They are used mainly by third party tools that >> statically analyze sources. They are rarely used at runtime. > > Even less used than docstrings probably. typing.NamedTuple and dataclasses use annotations at runtime. Eric ___

Re: [Python-ideas] Is there any idea about dictionary destructing?

2018-04-07 Thread Eric V. Smith
There was a long thread last year on a subject, titled "Dictionary destructing and unpacking.": https://mail.python.org/pipermail/python-ideas/2017-June/045963.html You might want to read through it and see what ideas and problems were raised then. In that discussion, there's also a link to

Re: [Python-ideas] Dart like multi line strings identation

2018-04-01 Thread Eric V. Smith
On 3/31/2018 9:48 PM, Steven D'Aprano wrote: On Sun, Apr 01, 2018 at 02:20:16AM +0100, Rob Cliffe via Python-ideas wrote: New unordered 'd' and 'D' prefixes, for 'dedent', applied to multiline strings only, would multiply the number of alternatives by about 5 and would require another rewrite

Re: [Python-ideas] Dart like multi line strings identation

2018-04-01 Thread Eric V. Smith
On 4/1/2018 8:55 AM, Chris Angelico wrote: On Sun, Apr 1, 2018 at 10:36 PM, Steven D'Aprano wrote: And that *mental complexity* is (in my opinion) the biggest issue with adding a new d-prefix, and why I would rather make it a method. Another big advantage of a method is

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Eric V. Smith
On 3/24/2018 5:49 AM, Chris Angelico wrote: On Sat, Mar 24, 2018 at 3:41 PM, Steven D'Aprano wrote: To keep this a manageable length, I've trimmed vigourously. Apologies in advance if I've been too enthusiastic with the trimming :-) On Sat, Mar 24, 2018 at 05:09:54AM

Re: [Python-ideas] Class autoload

2018-03-03 Thread Eric V. Smith
On 3/3/2018 12:12 PM, Jamesie Pic wrote: Hello everybody, I thought perhaps we could allow the usage of a "new" keyword to instanciate an object, ie:    obj = new yourmodule.YourClass() I'd just do: import yourmodule obj = yourmodule.YourClass() Or as one line, if that's your

Re: [Python-ideas] Python 3.7 dataclasses attribute order

2018-10-24 Thread Eric V. Smith
On 10/24/2018 5:30 AM, Anders Hovmöller wrote: Well that seems super unfortunate. You can opt out of the auto generate constructor and do it yourself:   @dataclass(init=False)   class Foo:       foo: str       bar: str = None       baz: str       def __init__(self, *, foo, bar = None,

Re: [Python-ideas] Serialization of CSV vs. JSON

2018-11-06 Thread Eric V. Smith
On 11/6/2018 6:46 AM, David Shawley wrote: On Nov 4, 2018, at 12:43 PM, Michael Selik > wrote: > If you're making a module >> > > On Sun, Nov 4, 2018, 5:49 AM David Shawley wrote: > > Personally, I would place this sort of

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 3:54 AM, Steven D'Aprano wrote: On Tue, Oct 02, 2018 at 08:27:03PM -0400, Eric V. Smith wrote: Here’s the idea: for f-strings, we add a !d conversion operator, which is superficially similar to !s, !r, and !a. The meaning of !d is: produce the text of the expression (not its value

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 12:23 AM, Tim Peters wrote: [Eric V. Smith mailto:e...@trueblade.com>>] Here’s the idea: for f-strings, we add a !d conversion operator, which is superficially similar to !s, !r, and !a. The meaning of !d is: produce the text of the expression (not its

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 1:40 AM, Nathaniel Smith wrote: On Tue, Oct 2, 2018 at 8:44 PM, David Teresi > wrote: > print(f'{value!d}') is a lot of symbols and boilerplate to type out just for > a debugging statement that will be deleted later. Especially now that > breakpoint()

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 5:29 AM, Jonathan Fine wrote: Hi Eric Summary: This email is mainly about process. One discussion thread or several. I think the decision is yours. You wrote suggesting an enhancement for debugging: Here’s the idea: for f-strings, we add a !d conversion operator, which is

Re: [Python-ideas] Simplicity of C (was why is design-by-contracts not widely)

2018-09-30 Thread Eric V. Smith
On 9/30/2018 8:11 AM, Stephen J. Turnbull wrote: Steven D'Aprano writes: > (7) You can't unit test loop invariants I don't see how a loop invariant can be elegantly specified without mixing it in to the implementation. Can you show an example of code written in a language with support for

Re: [Python-ideas] Transpiling contracts

2018-10-02 Thread Eric V. Smith
On 10/2/2018 11:05 AM, Marko Ristin-Kaufmann wrote: Hi Ned, The idea is to polish a proof-of-concept library and then try to introduce it into the standard libs eventually. I'd suggest taking this off-list until such a library is developed, then. But, if the library needs some hook provided

[Python-ideas] f-string "debug" conversion

2018-10-02 Thread Eric V. Smith
This idea was proposed to me at the core sprints last month by Larry Hastings. I've discussed it with a few people, who seem generally positive about it, and we've tweaked it a little bit. I've spent some time implementing it, and I think it's doable. I thought I'd post it here for any

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Eric V. Smith
On 10/3/2018 7:07 AM, Eric V. Smith wrote: On 10/3/2018 12:23 AM, Tim Peters wrote: [Eric V. Smith mailto:e...@trueblade.com>>]     Here’s the idea: for f-strings, we add a !d conversion operator, which     is superficially similar to !s, !r, and !a. The meaning of !d is:     p

Re: [Python-ideas] f-string "debug" conversion

2018-10-04 Thread Eric V. Smith
On 10/3/2018 8:47 PM, Tim Peters wrote: Note that transforming    {EXPR!d:FMT} into    EXPR={repr(EXPR):FMT} is actually slightly more involved than transforming it into    EXPR={EXPR:FMT} so I don't buy the argument that the original idea is simpler.  More magical and less useful, yes

Re: [Python-ideas] Fixed point format for numbers with locale based separators

2019-01-05 Thread Eric V. Smith
On 1/5/2019 3:03 PM, Łukasz Stelmach wrote: Barry Scott writes: On Friday, 4 January 2019 14:57:53 GMT Łukasz Stelmach wrote: I would like to present two pull requests[1][2] implementing fixed point presentation of numbers and ask for comments. The first is mine. I learnt about the second

Re: [Python-ideas] About the passing the function arguments in Keyword form.

2018-12-24 Thread Eric V. Smith
On 12/24/2018 5:21 AM, 李默 wrote: I am having an idea on loosing the argument validity check when passing the function arguments in keyword way. For example: --- deff(x, y): print(x, y) def call_f(): f(x=7, y=9, z=9) call_f() -- In the

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Eric V. Smith
On 1/7/2019 10:15 AM, Chris Angelico wrote: On Mon, Jan 7, 2019 at 11:11 PM Oscar Benjamin wrote: On Mon, 7 Jan 2019 at 09:27, Chris Angelico wrote: On Mon, Jan 7, 2019 at 7:11 PM Anders Hovmöller wrote: This proposal is basically about introducing goto to the language. A bit hyperbolic

Re: [Python-ideas] Combine f-strings with i18n

2018-09-17 Thread Eric V. Smith
See also PEP 501, which could be used for i18n. Eric On 9/17/2018 1:42 PM, Stephen J. Turnbull wrote: Hans Polak writes: > On 17/09/18 09:53, Niki Spahiev wrote: > > > > Is it possible to use f-strings when making multilingual software? > > When i write non-hobby software translation

Re: [Python-ideas] kwargs for return

2019-01-26 Thread Eric V. Smith
On 1/26/2019 12:30 PM, David Mertz wrote: On Sat, Jan 26, 2019 at 10:31 AM Steven D'Aprano > wrote: In what way is it worse, given that returning a namedtuple with named fields is backwards compatible with returning a regular tuple? We can have our

Re: [Python-ideas] New explicit methods to trim strings

2019-04-02 Thread Eric V. Smith
On 4/2/2019 2:02 PM, Rhodri James wrote: On 02/04/2019 18:55, Stephen J. Turnbull wrote: >> = Me   > 3. My most common use case (not very common at that) is for stripping   > annoying prompts off text-based APIs.  I'm happy using   > .startswith() and string slicing for that, though your point

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-01 Thread Eric V. Smith
Hi, Steven. I can help you with it. I added it as PEP 584. I had to add the PEP headers, but didn't do any other editing. I'm going to be out of town for the next 2 weeks, so I might be slow in responding. Eric On 3/1/2019 11:26 AM, Steven D'Aprano wrote: Attached is a draft PEP on

Re: [Python-ideas] Current use of addition in Python

2019-03-04 Thread Eric V. Smith
> On Mar 4, 2019, at 2:18 PM, Rhodri James wrote: > >> On 04/03/2019 14:03, Jonathan Fine wrote: >> Summary: This thread is for recording current use of addition in >> Python. > > TL;DR. Why is this is Python Ideas? Because of the current discussion of dict + dict. I think this is helping

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread Eric V. Smith
On 3/1/2019 9:38 AM, INADA Naoki wrote: Sorry, I'm not good at English enough to explain my mental model. I meant no skip, no ignorance, no throw away. In case of 1+2=3, both of 1 and 2 are not skipped, ignored or thrown away. On the other hand, in case of {a:1, b:2}+{a:2}={a:2, b:2}, I feel

Re: [Python-ideas] Dict joining using + and +=

2019-02-28 Thread Eric V. Smith
On 2/27/2019 2:08 PM, Guido van Rossum wrote: On Wed, Feb 27, 2019 at 11:06 AM João Matos > wrote: Great. Because I don't program in any other language except Python, I can't make the PR (with the C code). Maybe someone who program in C can help?

Re: [Python-ideas] Add list.join() please

2019-01-30 Thread Eric V. Smith
On 1/30/2019 5:07 AM, Jamesie Pic wrote: On Wed, Jan 30, 2019 at 7:03 AM Robert Vanden Eynde wrote: Raises an error. Why should: “”.join([2, “2”]) not raise an error as well? I agree What do you think could be the developer intent when they do ",".join([2, "2']) ? If the intent is

Re: [Python-ideas] Option of running shell/console commands inside the REPL

2019-02-01 Thread Eric V. Smith
On 2/1/2019 9:07 AM, James Lu wrote: I always use ptipython (ptpython shell over the ipython console) for my REPLs. The built-in python repl is not /batteries included/ in the sense that it already has what you need to explore the language. I wonder, what do the python committers think about

Re: [Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS

2019-02-01 Thread Eric V. Smith
On 2/1/2019 1:59 PM, Mike Miller wrote: On 1/30/19 6:07 PM, David Mertz wrote: On Wed, Jan 30, 2019, 4:23 PM Abe Dillon wrote:     Consider thatmath.pi and math.e are constants that are not all caps, have     you ever been tempted to re-bind those variables? I

Re: [Python-ideas] Consistency in naming [was Re: ...ALL CAPS]

2019-02-03 Thread Eric V. Smith
On 2/2/2019 11:56 PM, James Lu wrote: Sent from my iPhone On Feb 2, 2019, at 3:41 AM, Steven D'Aprano wrote: Python has been around not quite 30 years now, so we can expect that it will probably last another 30 years. But chances are not good that it will be around in 300 years. A big

Re: [Python-ideas] Mention more alternative implementations on the PSF website

2019-02-03 Thread Eric V. Smith
> On Feb 3, 2019, at 5:31 PM, James Lu wrote: > > https://www.python.org/download/alternatives/ should possibly mention: > > - Cython and Nuitka > - Mention the possibility of compiling Python to WASM >- WASM allows Web and Mobile use of Python at possibly native speed. > Though not

Re: [Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments

2019-04-12 Thread Eric V. Smith
Viktor is looking for something at the call site, not the function definition site (which he might not control). I wrote calllib (horrible name, I know). It can do this, although I just noticed it needs updating for keyword-only params. But, here it is without keyword-only params: >>> from

Re: [Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments

2019-04-12 Thread Eric V. Smith
On 4/12/2019 1:52 PM, Viktor Roytman wrote: That is an interesting solution. In the case of a function from another library, you could apply the decorator as needed like.     fief(func)(**{'a': 1, 'b': 2}) It looks a little strange, but I've seen stranger. Indeed. That's not so bad, and

Re: [Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments

2019-04-12 Thread Eric V. Smith
On 4/12/2019 11:29 AM, Rhodri James wrote: On 12/04/2019 16:10, Viktor Roytman wrote: Currently, unpacking a dict in order to pass its items as keyword arguments to a function will fail if there are keys present in the dict that are invalid keyword arguments: >>> def func(*, a): ... 

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-04 Thread Eric V. Smith
On 6/4/2019 8:38 AM, Steven D'Aprano wrote: On Tue, Jun 04, 2019 at 01:20:14PM +0100, Rhodri James wrote: On 04/06/2019 11:06, Yanghao Hua wrote: [...] what I needed is an operator that does not collide with all existing number/matrix operators. Why? That's the question that in all your

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-05-28 Thread Eric V. Smith
On 5/28/2019 4:29 PM, Yanghao Hua wrote: To repeat what the problem do I think I am solving? A variable, that behaves like an integer (e.g. all normal integer ops should just work), but has a different assignment behavior, such that it can be used to develop equally good hardware descriptions.

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-05-28 Thread Eric V. Smith
> On May 28, 2019, at 5:22 PM, Yanghao Hua wrote: > >> On Tue, May 28, 2019 at 10:40 PM Eric V. Smith wrote: >> >>> On 5/28/2019 4:29 PM, Yanghao Hua wrote: >>> >>> To repeat what the problem do I think I am solving? A variable, that >>>

Re: [Python-ideas] add an additional dataclasses.asdict option for non-dataclasses

2019-05-11 Thread Eric V. Smith
> On May 11, 2019, at 11:12 PM, Christopher Barker wrote: > >> On Sat, May 11, 2019 at 3:26 PM Eric V. Smith wrote: > >> It’s a design goal of dataclasses to not be iterable. >> >> https://www.python.org/dev/peps/pep-0557/#why-not-just-use-namedtuple >

Re: [Python-ideas] add an additional dataclasses.asdict option for non-dataclasses

2019-05-11 Thread Eric V. Smith
> On May 11, 2019, at 4:51 PM, Christopher Barker wrote: > >> On Sat, May 11, 2019 at 1:38 PM Brendan Barnwell >> wrote: > >> > protocol for something different -- I can't image what that would be. >> > Sure, on the general case, maybe, but for a class that has a "natural" >> > use case for

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-05-22 Thread Eric V. Smith
> On May 22, 2019, at 10:51 AM, Andre Roberge wrote: > > > >> On Wed, May 22, 2019 at 9:57 AM Yanghao Hua wrote: >> > > And this is something I have in mind for a Python DSL for HDL: > > Perhaps you might be able to do what you want using an import hook. I have > done some experiments with

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-19 Thread Eric V. Smith
On 5/18/2019 8:13 PM, Yonatan Zunger wrote: ... For example, this is a good pattern: with functionReturningFile(...) as input:    doSomething(input) There are many cases where an Optional[file] makes sense as a parameter, as well; for example, an optional debug output stream, or an input

Re: [Python-ideas] f-string "debug" conversion

2019-05-02 Thread Eric V. Smith
See https://bugs.python.org/issue36774. On 10/2/18 8:27 PM, Eric V. Smith wrote: This idea was proposed to me at the core sprints last month by Larry Hastings. I've discussed it with a few people, who seem generally positive about it, and we've tweaked it a little bit. I've spent some time

Re: [Python-ideas] f-string "debug" conversion

2019-05-03 Thread Eric V. Smith
tly more involved than transforming it into >> > >> > EXPR={EXPR:FMT} >> > >> > so I don't buy the argument that the original idea is simpler. More >> > magical and less useful, yes ;-) > > [Eric V. Smith] >> Actually, my proposal i

[Python-ideas] Re: Coding using Unicode

2019-07-15 Thread Eric V. Smith
On 7/15/2019 7:34 AM, Adrien Ricocotam wrote: Hi all, What would you think if we could write our code using unicode ? It would be especially useful for scientific programming (we could use the greek letters), it could also be nice to use emojis for some variables. I don't see any bad

[Python-ideas] Re: Coding using Unicode

2019-07-15 Thread Eric V. Smith
On 7/15/2019 7:43 AM, Adrien Ricocotam wrote: Oh ok ! I tried with some unicodes () but it didn't work. So it's only a subset as described in PEPs ? Correct. What about extending it ? The PEP has a rationale about why it works like it does. If you want to extend it, you should be

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-13 Thread Eric V. Smith
On 8/13/2019 5:49 PM, Andrew Barnert via Python-ideas wrote: But I think the lazy-import-decimal-on-first-dump-with-use_decimal solves that, and solves it even better than __json__, even besides the fact that it’s a better API than exposing “dump raw text into any JSON, and it’s up to you to

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-13 Thread Eric V. Smith
On 8/13/2019 8:53 PM, Steven D'Aprano wrote: On Tue, Aug 13, 2019 at 06:01:27PM -0400, Eric V. Smith wrote: dataclasses does something similar: it wants to know if something is a typing.ClassVar, but it doesn't want to import typing to find out. Why not? Is importing typing especially

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-10 Thread Eric V. Smith
On 8/10/2019 10:59 AM, Richard Musil wrote: Paul Moore wrote: So IMO, the next step is probably an issue on bpo, combined with a PR implementing the proposed behaviour. I don't think this is big enough to need a PEP, and I don't think any more debate is really needed here. Someone motivated

  1   2   3   4   >