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

[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

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

2019-08-10 Thread Eric V. Smith
On 8/10/2019 11:30 AM, Eric V. Smith wrote: 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

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Eric V. Smith
One way to handle this particular case would be to do it as a variant of f-string that doesn't join its arguments, but passes the list to some other function. Just replace the final step BUILD_STRING step with BUILD_LIST, then call the function. There'd need to be some way to recognize which

[Python-ideas] Re: for ... except, with ... except

2019-07-30 Thread Eric V. Smith
> On Jul 30, 2019, at 11:38 AM, Guido van Rossum wrote: > ... > > with connect() as stream: # connect() or __enter__() can fail. > for data in stream: # __next__() can fail > write(data) # write() can fail > > This very much looks like toy networking code to

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Eric V. Smith
On 7/26/2019 6:05 PM, Kyle Stanley wrote: Andrew Barnert wrote: consume(print(item) for item in lst) From my understanding, consume() effectively provides the functionality the author was looking for. Also, between the options of `for _ in iter:` vs `colllections.deque(it, maxlen=0)`, how

[Python-ideas] Re: PEP's shouldn't require a sponsor

2019-07-26 Thread Eric V. Smith
On 7/26/2019 11:21 AM, Geoffrey Spear wrote: On Thu, Jul 25, 2019 at 8:17 AM Batuhan Taskaya > wrote: Why do i need to convince a core developer for my PEP? AFAIK the steering council can include non core developers (i know it isn't that current case

[Python-ideas] Re: Skip modules by default in star-import

2019-07-26 Thread Eric V. Smith
On 7/26/2019 4:23 PM, Anders Hovmöller wrote: On 26 Jul 2019, at 20:58, Eric V. Smith wrote: On 7/26/2019 2:50 PM, Anders Hovmöller wrote: On 26 Jul 2019, at 20:34, Serhiy Storchaka wrote: 26.07.19 21:10, Anders Hovmöller пише: This doesn't really solve the problem imo. Imported

[Python-ideas] Re: Skip modules by default in star-import

2019-07-26 Thread Eric V. Smith
On 7/26/2019 2:50 PM, Anders Hovmöller wrote: On 26 Jul 2019, at 20:34, Serhiy Storchaka wrote: 26.07.19 21:10, Anders Hovmöller пише: This doesn't really solve the problem imo. Imported symbols shouldn't be i portable elsewhere. Not by import * or explicitly. That's the problem. I do

[Python-ideas] Re: Add __slots__ to dataclasses to use less than half as much RAM

2019-09-27 Thread Eric V. Smith
> On Sep 27, 2019, at 12:52 PM, Andrew Barnert via Python-ideas > wrote: > >  > On Friday, September 27, 2019, 07:47:41 AM PDT, Johnny Dahlberg > wrote: > > > My proposal: Implement `@dataclass(slots=True)` which does the same thing > > as attrs: Replaces the class with a modified class

[Python-ideas] Re: Add __slots__ to dataclasses to use less than half as much RAM

2019-09-27 Thread Eric V. Smith
On 9/27/2019 6:11 PM, Random832 wrote: On Fri, Sep 27, 2019, at 12:48, Andrew Barnert via Python-ideas wrote: or get rid of the guarantee that @dataclass returns your class with extra dunders. Why is dataclass a decorator instead of a metaclass (or, as below, pseudo-metaclass) anyway? Is it

[Python-ideas] Re: Add __slots__ to dataclasses to use less than half as much RAM

2019-09-27 Thread Eric V. Smith
> On Sep 27, 2019, at 8:23 PM, Guido van Rossum wrote: > >  >> On Fri, Sep 27, 2019 at 11:18 AM Serhiy Storchaka >> wrote: >> I think it needs an explicit support in the type creation machinery (as >> __slots__ itself has) to support descriptors and slots with the same name. > > That would

[Python-ideas] Re: Allow Path object instances in subprocess.Popen

2019-11-02 Thread Eric V. Smith
On 11/2/2019 7:24 PM, Steven D'Aprano wrote: I see no reason why this shouldn't be allowed. It seems like a straight-forward feature request, and one that is compatible with the basic idea that Path objects should be usable anywhere you need a file name. The problem is that in the given

[Python-ideas] Re: Allow Path object instances in subprocess.Popen

2019-11-03 Thread Eric V. Smith
On 11/2/2019 10:02 PM, Jonathan Goble wrote: On Sat, Nov 2, 2019 at 9:52 PM MRAB wrote: On 2019-11-03 00:38, Chris Angelico wrote: On Sun, Nov 3, 2019 at 11:34 AM Eric V. Smith wrote: On 11/2/2019 7:24 PM, Steven D'Aprano wrote: I see no reason why this shouldn't be allowed. It seems

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

2019-11-12 Thread Eric V. Smith
*/PEP 328 doesn’t seem to mention any of the names detailed below./* I strongly advise reading PEPs as documentation once their work has landed. At that point they are mostly historical documents and will not be kept up to date going forward. IOW do not read any import-related PEPs for

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

2019-12-09 Thread Eric V. Smith
On 12/9/2019 4:54 PM, Greg Ewing wrote: On 9/12/19 7:37 am, Guido van Rossum wrote: def first(it, /, default=None): it = iter(it) try: return next(it) except StopIteration: return default Can you provide any insight into why you think it's better for it never

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

2019-12-15 Thread Eric V. Smith
On 12/15/2019 2:21 PM, Christopher Barker wrote: On Sun, Dec 15, 2019 at 6:40 AM David Mertz > wrote: Yes, of course. I was just trying to illustrate using next() in a non-artificial way. In real code (but truthfully, probably not in my quick "one off"

[Python-ideas] Re: frozen dataclasses attribute initialization

2019-12-12 Thread Eric V. Smith
On 12/12/2019 5:05 AM, Arthur Pastel wrote: On Thu, Dec 12, 2019 at 2:03 AM Eric V. Smith <mailto:e...@trueblade.com>> wrote: On 12/11/2019 6:36 PM, Arthur Pastel wrote: >> Add an extra hidden attribute to every instance just >> to track whether you’re in

[Python-ideas] Re: frozen dataclasses attribute initialization

2019-12-12 Thread Eric V. Smith
On 12/12/2019 8:07 AM, Arthur Pastel wrote: On Thu, Dec 12, 2019 at 2:03 AM Eric V. Smith mailto:e...@trueblade.com>> wrote: On 12/11/2019 6:36 PM, Arthur Pastel wrote: >> Add an extra hidden attribute to every instance just >> to track whe

[Python-ideas] Re: frozen dataclasses attribute initialization

2019-12-12 Thread Eric V. Smith
On 12/12/2019 8:50 AM, Arthur Pastel wrote: On 12/12/2019 8:07 AM, Arthur Pastel wrote: On Thu, Dec 12, 2019 at 2:03 AM Eric V. Smith mailto:e...@trueblade.com>> wrote: On 12/11/2019 6:36 PM, Arthur Pastel wrote: >> Add an extra hidd

[Python-ideas] Re: frozen dataclasses attribute initialization

2019-12-11 Thread Eric V. Smith
On 12/11/2019 1:23 PM, Andrew Barnert via Python-ideas wrote: On Dec 11, 2019, at 08:56, Arthur Pastel wrote: When creating frozen dataclasses, attribute initialization must be done using `object.__setattr__()` it would be nice to allow attribute assignment in the `__init__` and

[Python-ideas] Re: frozen dataclasses attribute initialization

2019-12-11 Thread Eric V. Smith
On 12/11/2019 6:36 PM, Arthur Pastel wrote: If dataclass handled freezeable types (the objects are mutable until you call freeze, after which they’re not), this would be easy (frozen now just means freezable, plus freeze is called by the generated __init__ right after the __post_init__). But

[Python-ideas] Re: foo.setParseAction(lambda a, b, c: raise FuckPython(":("))

2019-10-27 Thread Eric V. Smith
On 10/27/2019 10:35 AM, Soni L. wrote: that's a waste of a perfectly good name in the namespace. Names are cheap. If "wasting" a name is a concern, then perhaps Python isn't the language for you. It also lacks local scopes inside code blocks, for example, which also "waste" names, as

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

2019-11-30 Thread Eric V. Smith
On 11/30/2019 8:51 PM, Andrew Barnert via Python-ideas wrote: On Nov 30, 2019, at 16:36, Oscar Benjamin wrote: On Sat, 30 Nov 2019 at 22:24, Steven D'Aprano wrote: On Sat, Nov 30, 2019 at 06:16:49PM -0300, Soni L. wrote: It'd be quite nice if dict.items() returned a namedtuple so all these

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

2019-11-27 Thread Eric V. Smith
On 11/27/2019 3:24 PM, Abdur-Rahmaan Janhangeer wrote: Greetings list, Using 3.7, in json module of the std lib there is json.load and json.loads . I gather json.loads is more used to convert string to dict structure. json.load might cause (it already causes) confusions. Suggestion: Rename

[Python-ideas] Re: Request: pointers to exemplar threads from python-ideas?

2019-11-29 Thread Eric V. Smith
Hi, Titus. I’m not sure if this fits the bill, but this is the discussion that led to PEP 498 and f-strings: https://mail.python.org/pipermail/python-ideas/2015-July/034657.html -- Eric V. Smith (301) 502-0945 cell > On Nov 29, 2019, at 9:02 AM, C. Titus Brown wrote: > >

[Python-ideas] Re: Allow kwargs in __{get|set|del|}item__

2019-10-08 Thread Eric V. Smith
On 10/8/2019 5:53 PM, Eric V. Smith wrote: On 10/8/2019 4:53 PM, Random832 wrote: On Tue, Oct 8, 2019, at 14:18, Anders Hovmöller wrote: I don't see it. Can you give examples of all the variations of slicing and their keyword equivalent so I understand what you mean? I'll write out

[Python-ideas] Re: Allow kwargs in __{get|set|del|}item__

2019-10-08 Thread Eric V. Smith
On 10/8/2019 4:53 PM, Random832 wrote: On Tue, Oct 8, 2019, at 14:18, Anders Hovmöller wrote: I don't see it. Can you give examples of all the variations of slicing and their keyword equivalent so I understand what you mean? I'll write out the slicing variants and you can fill in how it would

[Python-ideas] Re: Resolve append/add API inconsistency between set and list

2019-10-13 Thread Eric V. Smith
On 10/13/2019 5:57 PM, Steven D'Aprano wrote: On Sun, Oct 13, 2019 at 07:20:29PM -, Steve Jorgensen wrote: Failing fast is good, but it is also a very common case to want to add an item to a collection regardless of whether it is set-like or sequence-like. Is that correct though? To the

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

2019-12-20 Thread Eric V. Smith
[[fill]align][sign][#][0][width][grouping_option][.precision][#|$][type] Could not distinguish the first and second #: everything between them is optional. Eric On 12/20/2019 7:13 AM, Michael Amrhein wrote: Eric V. Smith wrote: ... The current specification for the format spec is: [[fill

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Eric V. Smith
On 2/24/2020 2:59 PM, Guido van Rossum wrote: The biggest problem remains that 99% of your explanation (and that of others who seem to understand what you want) uses the words of the application domain (statistics, stochastic variables, distributions) in a way that is unhelpful to convey your

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Eric V. Smith
On 2/24/2020 4:20 PM, Alex Hall wrote: Just add the appropriate code to filter that category of warnings. I think you have the option of two lines of Python code or one environment variable. I can assure you that many users will not know how to do either of those things. Eric On Mon,

[Python-ideas] Re: Really long ints

2020-02-04 Thread Eric V. Smith
On 2/4/2020 6:17 PM, Ricky Teachey wrote: Why not just build the number using some kind of fancy "continuing integer" constructor function? Then you could just use commas, Blacken the code, and it will look great, right? P = my_int_maker(29674495668685510550154174642905332730771991,        

[Python-ideas] Re: allow full expressions in decorators

2020-02-04 Thread Eric V. Smith
On 2/4/2020 4:07 AM, Ben Avrahami wrote: Thanks for the reply! Is this really deserving of a PEP? It's such a minor change in the language, can't it be resolved as a python issue? Out of curiosity, why have you always resisted changing this? PEP-318 references

[Python-ideas] Re: `raise as` to raise with current exception as cause

2020-02-08 Thread Eric V. Smith
On 2/7/2020 11:08 PM, Andrew Barnert via Python-ideas wrote: On Feb 7, 2020, at 16:11, Steven D'Aprano wrote: Shai Berger wants to set it implicily, based on where the raise is. If it is "directly" under the except line, implicitly set the cause. It seems like a truly bad idea to change the

[Python-ideas] Re: Annotated string literals

2020-02-02 Thread Eric V. Smith
On 2/2/2020 8:28 PM, Soni L. wrote: It'd be cool to attach metadata to string literals that doesn't end up in the resulting string object. This metadata could be used by all sorts of tools, everything from localization to refactoring. In C, some localization libraries use macros for it, such

[Python-ideas] Re: Function call in (kw)args

2020-02-09 Thread Eric V. Smith
On 2/9/2020 7:34 AM, Soni L. wrote: I propose that: def foo(print(x)):   pass becomes: def foo(x):   x = print(x)   pass or, alternatively we could have decorators in function args: def foo(@print x):   pass which would probably be more aligned with the rest of python actually. anyway,

[Python-ideas] Re: PEP 614: Relaxing Grammar Restrictions On Decorators

2020-02-11 Thread Eric V. Smith
On 2/11/2020 10:58 AM, Brandt Bucher wrote: I have just pushed the first draft of PEP 614: https://www.python.org/dev/peps/pep-0614/ It proposes that the current decorator syntax restrictions be relaxed to allow any valid expression. Please let me know what you think! I think it should

[Python-ideas] Re: New syntax for decorators that are compatible with both normal and async functions

2020-02-11 Thread Eric V. Smith
On 2/11/2020 2:33 AM, Ben Rudiak-Gould wrote: On Mon, Feb 10, 2020 at 9:50 AM Andrew Barnert via Python-ideas wrote: It’s a well-known problem that async is “contagious”: [...] But C# and every other language that’s borrowed the idea has the same problem, and as far as I know, nobody’s

[Python-ideas] Re: Change List Metadata

2020-01-15 Thread Eric V. Smith
On 1/14/2020 11:03 PM, Hunter Jones wrote: Hey everyone, I recently used list.count() in a coding interview and the question arose about how scale-able this solution was for sufficiently large input. Currently, list.count iterates through the list, incrementing the count as it goes and

[Python-ideas] Re: Change List Metadata

2020-01-15 Thread Eric V. Smith
On 1/15/2020 7:43 PM, Kyle Stanley wrote: > I suggest that when you need this functionality you create your own data > structure combining a list and a collections.Counter and keep track of > this yourself. I concur with the usage of collections.Counter here. Storing the count for every

[Python-ideas] Re: addition of "nameof" operator

2020-01-21 Thread Eric V. Smith
On 1/21/2020 2:25 PM, Chris Angelico wrote: Hmm. Maybe this should be a recipe in the docs, or something: "how to make a repr that reconstructs an object". def describe(obj, attrs): attrs = [f"{a}={getattr(obj, a)!r}" for a in attrs] return f"{type(obj).__name__}({", ".join(attrs)})"

[Python-ideas] Re: addition of "nameof" operator

2020-01-21 Thread Eric V. Smith
On 1/21/2020 4:32 PM, Andrew Barnert via Python-ideas wrote: What would the semantics of nameof be in Python? Would it just be lambda obj: obj.__name__? Or some fancy inspect-module style chain of “try this, then that, then the other”? Or does it need to look at the compiled source code

[Python-ideas] Re: addition of "nameof" operator

2020-01-21 Thread Eric V. Smith
On 1/21/2020 4:50 PM, Eric V. Smith wrote: On 1/21/2020 4:32 PM, Andrew Barnert via Python-ideas wrote: What would the semantics of nameof be in Python? Would it just be lambda obj: obj.__name__? Or some fancy inspect-module style chain of “try this, then that, then the other”? Or does

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

2019-12-27 Thread Eric V. Smith
On 12/27/2019 10:37 AM, Marco Sulla via Python-ideas wrote: Eric Fahlgren wrote: You apparently did not read the posts, because the point was whether it raises or returns a default value, not whether it saves one line or ten. You apparently don't know Python: Please be more respectful. ```

[Python-ideas] Re: Testing for NANs [was Re: Fix statistics.median()?]

2019-12-28 Thread Eric V. Smith
On 12/28/2019 5:39 AM, Antoine Pitrou wrote: On Fri, 27 Dec 2019 23:52:13 -0800 Christopher Barker wrote: On Fri, Dec 27, 2019 at 5:39 PM Guido van Rossum wrote: Is duck typing float or Decimal worth the bother? Barring that it could be done with some isinstance() checks (in the user code,

[Python-ideas] Re: Exception spaces

2020-04-11 Thread Eric V. Smith
On 4/11/2020 9:38 AM, Soni L. wrote: On 2020-04-11 10:27 a.m., Eric V. Smith wrote: tl;dr: I show how the goal of Soni L's exception spaces can be addressed today, via less intrusive means. (Assuming I understand their proposal, that is.) what's the point of having standard types if you're

[Python-ideas] Re: Exception spaces

2020-04-11 Thread Eric V. Smith
tl;dr: I show how the goal of Soni L's exception spaces can be addressed today, via less intrusive means. (Assuming I understand their proposal, that is.) On 4/11/2020 7:49 AM, Soni L. wrote: On 2020-04-11 8:38 a.m., Chris Angelico wrote: On Sat, Apr 11, 2020 at 9:30 PM Soni L. wrote: > >

[Python-ideas] Re: Should dataclass init call super?

2020-04-15 Thread Eric V. Smith
that can't change, but there were reasons). If Eric V Smith is about I'm sure he could provide insight, or links to the relevant conversations. Sorry, I've been tied up on other things. In general, it's not possible to know how to call super.__init__() if you don't a priori know the arguments

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Eric V. Smith
On 4/17/2020 12:28 PM, Chris Angelico wrote: On Sat, Apr 18, 2020 at 1:54 AM David Mertz wrote: Hmmm... I disagree with Chris. I'm definitely -1 on a magic dangling 'foo=' after variable names. And something less than -1 on the even more magic "Lisp symbol that isn't a symbol" ':foo'. Those

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-16 Thread Eric V. Smith
On 4/16/2020 1:30 PM, Rhodri James wrote: On 16/04/2020 17:57, oliveira.rodrig...@gmail.com wrote: @StevenDAprano and this goes for @RhodriJames , thank you for sharing your point of view. Indeed the proposed syntax is obscure and would not be that readable for beginners. Couldn't we work

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-19 Thread Eric V. Smith
On 4/19/2020 7:23 AM, Richard Damon wrote: On 4/19/20 1:48 AM, Stephen J. Turnbull wrote: Chris Angelico writes: > Except that render_template isn't one of my own functions. It's part > of the templating engine (this is a Flask web app). There is no > refactoring to do - that IS the

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-20 Thread Eric V. Smith
On 4/20/2020 3:39 PM, Andrew Barnert via Python-ideas wrote: On Apr 20, 2020, at 11:25, Brandt Bucher wrote: I disagree. In my own personal experience, ~80% of the time when I use `zip` there is an assumption that all of the iterables are the same length. Sure, but I think cases where you

[Python-ideas] Re: zip should return partial results in StopIteration

2020-04-21 Thread Eric V. Smith
On 4/21/2020 10:10 AM, Soni L. wrote: I feel like zip could return partial results: try:   next(zip([0], [])) except StopIteration as exc:   assert StopIteration.args == (0,) how much would this break? It would break a lot of code, and so it won't happen. You can use itertools.zip_longest

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-21 Thread Eric V. Smith
On 4/21/2020 9:51 AM, Chris Angelico wrote: On Tue, Apr 21, 2020 at 7:01 PM M.-A. Lemburg wrote: Instead of keeping values in local variables, you store them in the namespace object and because this knows about its attributes you can do a lot more in terms of introspection than what is

[Python-ideas] Re: zip should return partial results in StopIteration

2020-04-21 Thread Eric V. Smith
On 4/21/2020 10:14 AM, Eric V. Smith wrote: On 4/21/2020 10:10 AM, Soni L. wrote: I feel like zip could return partial results: try:   next(zip([0], [])) except StopIteration as exc:   assert StopIteration.args == (0,) how much would this break? It would break a lot of code, and so it won't

[Python-ideas] Re: Proposal: Keyword Unpacking Shortcut [was Re: Keyword arguments self-assignment]

2020-04-19 Thread Eric V. Smith
On 4/18/2020 2:03 PM, David Mertz wrote: > f(**{u, v}) I think a fundamental point is that `**{identifier}` looks like you are applying `**` unpacking to a set, but you actually aren't, it is a special syntactic form. If that disturbs you, I'm not going to say you are wrong.

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Eric V. Smith
On 4/20/2020 7:27 AM, Ivan Levkivskyi wrote: On Mon, 20 Apr 2020 at 12:19, Eric V. Smith <mailto:e...@trueblade.com>> wrote: See PEP 3113, which doesn't mention parsing. My understanding is that it was the introspection problem that drove this. And on very rare occ

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-20 Thread Eric V. Smith
On 4/20/2020 7:00 AM, Steven D'Aprano wrote: On Mon, Apr 20, 2020 at 10:03:50AM +0200, M.-A. Lemburg wrote: Guys, is it really worth saving a few hits on the auto-complete key by adding even more mysterious twists to the existing Python function call syntax ? The current version already

[Python-ideas] Re: Should dataclass init call super?

2020-04-16 Thread Eric V. Smith
d library, they do need to remain pretty stable, but there's still room for extending them. But it's a bit hard when ideas and PRs are mingled in with everything else Python. Maybe a gitHub repo just for dataclasses? @Eric V. Smith <mailto:e...@trueblade.com>: what do you think? IS ther

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-17 Thread Eric V. Smith
On 4/17/2020 9:28 AM, Chris Angelico wrote: On Fri, Apr 17, 2020 at 8:52 PM Alex Hall wrote: But this means the reader could miss the star, especially with a very large function call over multiple lines, and if that reader happens to use that particular function A LOT and know the parameter

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-15 Thread Eric V. Smith
On 3/15/2020 12:50 PM, Steve Jorgensen wrote: Guido van Rossum wrote: I think the idea you're looking for is an alternative for the pprint module that allows classes to have formatting hooks that get passed in some additional information (or perhaps a PrettyPrinter object) that can affect the

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-04-02 Thread Eric V. Smith
I'm assuming here that the goal is to make string building easier, better, and/or more discoverable, and that the io.StringIO discussion is just one way to achieve this. For example, I don't think (but maybe I'm wrong) that "must be a file-like object" is a goal here. If that's not the goal,

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-21 Thread Eric V. Smith
On 4/21/2020 7:07 PM, Antoine Pitrou wrote: On Wed, 22 Apr 2020 08:34:56 +1000 Steven D'Aprano wrote: On Tue, Apr 21, 2020 at 12:09:44PM +0300, Serhiy Storchaka wrote: 21.04.20 11:15, Antoine Pitrou пише: Of course, the fact that zip() is the shorter form that everyone is used to means that,

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Eric V. Smith
On 5/1/2020 9:21 AM, André Roberge wrote: On Fri, May 1, 2020 at 10:15 AM Rhodri James > wrote: On 01/05/2020 07:48, Ram Rachum wrote: > There are 2 reasons I want this: > > 1. When I'm writing a try..except clause, I want to catch a specific

  1   2   3   4   >