[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-27 Thread Steven D'Aprano
On Sat, Dec 26, 2020 at 11:23:16AM -, Anton Abrosimov wrote: > I am trying to release comfortable dataclass unpacking using `**` > operator. Now I have 5 different ways to do it. But not a single good > one. Confused by the implementation of the unpacking operator. > > So when I try to

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-27 Thread Steven D'Aprano
On Sat, Dec 26, 2020 at 09:18:09PM -0800, Brendan Barnwell wrote: > >Yes it is documented: > > > > help(dict.update) > > > >and it was intentionally the inspiration for the behaviour of dict > >augmented assignment. > > I see. It's rather disturbing that that isn't mentioned in the

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread Cade Brown
You should really just write your own function -- Python can't include every validation function you can think of. It already provides an extensible and well tested float conversion which throws an exception on bad input (the 'float' constructor) You want it to not throw an exception, but rather

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread 2QdxY4RzWzUUiLuE
On 2020-12-27 at 19:55:39 -0300, "Joao S. O. Bueno" wrote: > I tried to make clear this should be in addition to that - But yes, I > failed to mention in my message that I think such a function would > mostly benefit beginners learning around with "input" and "print" - it > is painful to

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread Chris Angelico
On Mon, Dec 28, 2020 at 9:55 AM Joao S. O. Bueno wrote: > On Sun, 27 Dec 2020 at 19:31, Chris Angelico wrote: > Sorry, I thought my message conveyed that I know "float" exists, and > try/except is the current usable pattern (it is in the original posting > anyway) And my point is that

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread Joao S. O. Bueno
On Sun, 27 Dec 2020 at 19:31, Chris Angelico wrote: > On Mon, Dec 28, 2020 at 9:22 AM Joao S. O. Bueno > wrote: > > > > I agree - the three builtin methods are almost the same (not sure if > > there is any difference at all), > > Yes - they all check if the string matches a particular set of

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread Chris Angelico
On Mon, Dec 28, 2020 at 9:22 AM Joao S. O. Bueno wrote: > > I agree - the three builtin methods are almost the same (not sure if > there is any difference at all), Yes - they all check if the string matches a particular set of characters. > while there is no trivial way to check for a valid >

[Python-ideas] Re: str.isfloat()

2020-12-27 Thread Joao S. O. Bueno
I agree - the three builtin methods are almost the same (not sure if there is any difference at all), while there is no trivial way to check for a valid float, or otherwise a chosen representation of a decimal number without resorting to a try-except statement, or complicated verification schemes

[Python-ideas] str.isfloat()

2020-12-27 Thread Tushar Sadhwani
str currently has methods like isdecimal, isnumeric and isdigit, but there isn't an isfloat check, which could be very handy. a trivial implementation could be as simple as: try: float(self) return True except ValueError: return False

[Python-ideas] Re: Add aggregations and joins code-generating library along with itertools

2020-12-27 Thread Anton Abrosimov
1. I think this is too complex for the stdlib. One tool should do one thing. What about the PEP for this project? 2. This is very particular. For those who often convert data in different ways, but do not use pandas, attrs, SQL... 3. What about `typing`? 4. OTF code generation (if I understood

[Python-ideas] Add aggregations and joins code-generating library along with itertools

2020-12-27 Thread Nikita Almakov
Hello everyone! The idea: it would be cool to have the functionality of "convtools" library available along with "itertools". Python should provide decent functionality of aggregations and joins out-of- the-box. Given that named tuples generate some could, this one could too:

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-27 Thread Anton Abrosimov
Christopher Barker wrote: > My first thought is that for dataclasses, you can use the asdict() method, > and you're done. I thought in a similar way. I'll ask another (7K wtf in 2 years, 3 month) question about converting a dataclass to dict. ___

[Python-ideas] Re: Unpack operator "**" and Mapping

2020-12-27 Thread Anton Abrosimov
0. I believe that the `dict` behavior needs to be frozen. The change will break a lot of existing code, it's too much damage. 0.1. Yes, `keys` is not a good name for internal use, but that's okay. 0.2. If I want to make a class look like a `dict`, I understand that I will get `keys`, `items`...