[Python-ideas] Re: Generalized deferred computation in Python

2022-06-22 Thread Neil Girdhar
Could this idea be used to specify the default factory of a dataclass field? For example, @dataclass class X: x: list[int] = deferred [] instead of @dataclass class X: x: list[int] = field(default_factory=list) If so, it might be worth adding to your proposal as another common

[Python-ideas] Would it be desirable to save the state of functools.cache?

2022-05-24 Thread Neil Girdhar
Would it be desirable to save the state of functools.cache between program executions? For example, by providing cache_state property on the cache that is pickle-able.___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an

[Python-ideas] Please consider making dataclasses define an empty __post_init__

2022-02-20 Thread Neil Girdhar
This was discussed here: https://bugs.python.org/issue46757 This came up because I had a dataclass subclass to flax.linen.Module that had its own post-init. When I figured out that I needed to call super, I did so. Later, when I refactored my code to remove the superclass, the super-call

[Python-ideas] Re: Please consider mentioning property without setter when an attribute can't be set

2022-02-11 Thread Neil Girdhar
I humbly disagree that any of what you wrote is "obvious". On Fri, Feb 11, 2022 at 4:41 AM Steven D'Aprano wrote: > On Thu, Feb 10, 2022 at 02:27:42PM -0800, Neil Girdhar wrote: > > > AttributeError: can't set attribute 'f' > > > > This can be a pain to

[Python-ideas] Please consider mentioning property without setter when an attribute can't be set

2022-02-10 Thread Neil Girdhar
Hello, consider: class C: @property def f(self) -> int: return 2 class D(C): pass D().f = 2 Gives: Traceback (most recent call last): File "/home/neil/src/cmm/a.py", line 10, in D().f = 2 AttributeError: can't set attribute 'f' This can be a pain to debug when the

[Python-ideas] Re: Consider moving abstract method checking logic from ABCMeta into object

2022-02-08 Thread Neil Girdhar
On Tue, Feb 8, 2022 at 5:50 AM Paul Moore wrote: > On Tue, 8 Feb 2022 at 00:09, Neil Girdhar wrote: > > > > Currently, some type checkers rightly complain that a method is > decorated with abc.abstractmethod when the class's type does not inherit > from ABCMeta. Adding a

[Python-ideas] Consider moving abstract method checking logic from ABCMeta into object

2022-02-07 Thread Neil Girdhar
Currently, some type checkers rightly complain that a method is decorated with abc.abstractmethod when the class's type does not inherit from ABCMeta. Adding a metaclass is a fairly heavy dependency since you're forced to poison all of your other metaclasses with the same base metaclass. It

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-18 Thread Neil Girdhar
Even if f{1} creates a frozenset, I don't think f{} should create a frozenset. I think it makes more sense to keep f{1: 2} open for frozendict if it ever makes it in. Also, {} should be consisten with f{} (both should create dicts). If you want an empty frozenset, you would have to do it the

[Python-ideas] Re: staticmethod vs classmethod [was: Add a decorators called @staticproperty]

2022-01-05 Thread Neil Girdhar
Totally agree with this. I think both of points should be clarified in the documentation: https://docs.python.org/3/library/functions.html#staticmethod Namely that: * Nearly all uses of static methods should instead be class methods, and * The main exception is setting an ordinary function as a

[Python-ideas] Re: Applications user/system directories functions

2021-12-15 Thread Neil Girdhar
+1 for appdirs. It's a shame that more projects don't yet use it. On Wednesday, December 15, 2021 at 9:03:07 AM UTC-5 Matt del Valle wrote: > There is appdirs which does precisely what you're looking for: > > https://pypi.org/project/appdirs/ > > That said, it does seem to be a core bit of

[Python-ideas] Re: Python standard library TOML module

2021-12-13 Thread Neil Girdhar
FYI: The flake8 project refuses to add toml configuration file support in part because there is no standard library toml module: https://github.com/PyCQA/flake8/issues/234#issuecomment-812800722 The thread was eventually locked by the project owner, and a project sprang up to try to address

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Neil Girdhar
On Monday, December 6, 2021 at 6:28:10 PM UTC-5 Steven D'Aprano wrote: > On Mon, Dec 06, 2021 at 11:57:11AM -0800, Neil Girdhar wrote: > > > Has anyone done a survey of, say, the cpython library codebase to see > what > > proportion of arguments lists would signi

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Neil Girdhar
Has anyone done a survey of, say, the cpython library codebase to see what proportion of arguments lists would significantly benefit from this PEP given as a proportion of the total codebase? In all the Python I've ever written or seen, I can only thing of one example of a custom sentinel ever

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Neil Girdhar
On Wednesday, December 1, 2021 at 1:18:33 AM UTC-5 Chris Angelico wrote: > I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ > with some additional information about the reference implementation, > and some clarifications elsewhere. > > *PEP 671: Syntax for late-bound

[Python-ideas] Re: extending ast.parse with some lib2to3.pytree features

2021-11-20 Thread Neil Girdhar
I wish this had gotten more attention! :) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Unpacking in tuple/list/set/dict comprehensions

2021-11-13 Thread Neil Girdhar
> I propose (not for the first time) that similarly concatenating an unknown number of iterables or dicts should be possible via comprehensions: I'm really happy to see this feature proposal come up again! Every time, it seems this feature is even more intuitive to even more people, and I'm

[Python-ideas] Re: Adding pep8-casing-compliant aliases for the entire stdlib

2021-11-13 Thread Neil Girdhar
I like this comment. The proposal to change list and str is way too ambitious. But some minor cleanup might not be so pernicious? On Saturday, November 13, 2021 at 5:31:49 PM UTC-5 Mike Miller wrote: > > I like this idea and disappointed it always gets a negative reaction. One > of my >

[Python-ideas] Re: Deprecate sum of lists

2021-06-22 Thread Neil Girdhar
As someone who originally worked on implementing PEP 448, I wanted to chime in that while I agreed with the decision to be conservative when adding new features, I originally hoped that [*x for x in xs] would eventually make its way into Python. To me, it seemed intuitive and I hoped people

[Python-ideas] Re: symbolic math in Python

2021-06-01 Thread Neil Girdhar
Tue, Jun 1, 2021 at 6:47 AM Neil Girdhar wrote: > > On Tue, Jun 1, 2021 at 6:28 AM Oscar Benjamin > wrote: > > > > On Tue, 1 Jun 2021 at 10:53, Neil Girdhar wrote: > > > > > > On Tue, Jun 1, 2021 at 5:39 AM Oscar Benjamin > > > wrote: > &

[Python-ideas] Re: symbolic math in Python

2021-06-01 Thread Neil Girdhar
On Tue, Jun 1, 2021 at 6:28 AM Oscar Benjamin wrote: > > On Tue, 1 Jun 2021 at 10:53, Neil Girdhar wrote: > > > > On Tue, Jun 1, 2021 at 5:39 AM Oscar Benjamin > > wrote: > > > > > > On Tue, 1 Jun 2021 at 05:16, Neil Girdhar wrote: > > &

[Python-ideas] Re: symbolic math in Python

2021-06-01 Thread Neil Girdhar
On Tue, Jun 1, 2021 at 5:39 AM Oscar Benjamin wrote: > > On Tue, 1 Jun 2021 at 05:16, Neil Girdhar wrote: > > > > Hi Oscar, > > > > The problem that the original poster was trying to address with > > additional syntax is the automatic naming of symbols. He wa

[Python-ideas] Re: symbolic math in Python

2021-05-31 Thread Neil Girdhar
Have you considered using the JAX library's trick of decorating functions to provide automatic symbols? For example, your problem could be done in current Python with an appropriately-coded library: @symbolic def f(x, a, b, c): return a * x ** 2 + b * x + c sentinel = Sentinel()

[Python-ideas] Re: Changing The Theme of Python Docs Site

2021-05-05 Thread Neil Girdhar
I agree with the comment about removing full justification. Also, I think the Masonite docs' navigation is far superior to the Python docs. I like the full contents on the left, along with the version button, and the local jump on the right. The python docs require you to navigate somehwere

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-12 Thread Neil Girdhar
This is a great discussion. However, there's one issue that seems to be getting lost. Consider this library structure: test/lemon test/lemon/__init__.py test/module.py where test/module.py is: __all__ = ['lemon'] def lemon(): pass and test/__init__.py is: from .module import * from

[Python-ideas] Re: Add an export keyword to better manage __all__

2021-04-10 Thread Neil Girdhar
I like the idea of improving the way interfaces are exported in Python. I still don't know what the standard is today. Some of my favourite projects like Jax have started tucking their source in a _src directory: https://github.com/google/jax/tree/master/jax/_src, and then importing the

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 7:19 PM Chris Angelico wrote: > > On Fri, Jan 22, 2021 at 11:10 AM Random832 wrote: > > > > On Thu, Jan 21, 2021, at 18:48, Chris Angelico wrote: > > > Note that slicing is NOT easy. The proposed semantics for a reversed > > > enumeration would make slicing extremely odd.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 3:13 PM Christopher Barker wrote: > > On Thu, Jan 21, 2021 at 10:43 AM Neil Girdhar wrote: >> >> > > I've seen this proposed here before. The general idea is that some >> > > iterator transformations (like enumerate) should return se

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 1:26 PM Chris Angelico wrote: > > On Fri, Jan 22, 2021 at 5:21 AM Neil Girdhar wrote: > > > > I've seen this proposed here before. The general idea is that some > > iterator transformations (like enumerate) should return sequences when > >

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
I've seen this proposed here before. The general idea is that some iterator transformations (like enumerate) should return sequences when they're applied to sequences. I think it's good idea, but it adds complexity and work, which I guess needs to be justified on a case-by-case basis. In

[Python-ideas] Re: Consider having numbers.Real provide __complex__?

2021-01-18 Thread Neil Girdhar
Thanks for the correction Mark, I didn't realize that! Shantanu is right about what my ask was meant to be. I guess I'm nowhere near the first to propose things like this and there's a lot of discussion in various threads about it that I wasn't aware of. Best, Neil On Monday, January 18,

[Python-ideas] Consider having numbers.Real provide __complex__?

2021-01-18 Thread Neil Girdhar
I've been following along various issues in mypy regarding challenges with getting the ABCs in numbers (https://docs.python.org/3/library/numbers.html) working. Currently, there's a lot of clever logic in the functions int, float, and complex. Currently, inheriting from Real doesn't give you

[Python-ideas] Multiple dispatch for comparison operators?

2020-10-27 Thread Neil Girdhar
The way I understand it, multiple dispatch is programming language feature wehreby a function or method overload is chosen based on run time types. Python already has single dispatch (functools.singledispatch). It also has the concept of overloads for type annotations (typing.overload). My

[Python-ideas] Re: 'Infinity' constant in Python

2020-10-27 Thread Neil Girdhar
You might be interested in https://pypi.org/project/extended-int/ On Sunday, September 6, 2020 at 12:41:04 AM UTC-4 Cade Brown wrote: > Fair enough, I guess people have managed without it and there are plenty > of "good-enough" solutions for this that can be used in the place. > > I can see

[Python-ideas] Consider allow functools.singledispatch to work with typing.Union?

2020-08-26 Thread Neil Girdhar
Julia's burgeoning popularity has renewed my interest in dynamic dispatch. It seems to me that many methods that have been written as a giant switch on types can more clearly be written using dynamic dispatch. It was prettty exciting to see that Python already has single dispatch built in,

[Python-ideas] Re: Default behavior for random.sample when no k

2020-08-01 Thread Neil Girdhar
Can you not just use https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.random_permutation ? On Saturday, August 1, 2020 at 2:26:23 PM UTC-4 Ram Rachum wrote: > I would also prefer a `random.shuffled` function. The reason I didn't > propose it is because there's usually

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-10 Thread Neil Girdhar
What the future of this? I looked at type annotations in networkx recently ( https://github.com/networkx/networkx/pull/4014), and I wanted to keep things simple, so I proposed and implemented Graph[NodeType] However, I knew that they may ultimately want Graph[NodeType, EdgeTypedDict,

[Python-ideas] Re: Add __eq__ to colletions.abc.Sequence ?

2020-07-05 Thread Neil Girdhar
Are all objects in Python equality-comparable? I know that you can delete __hash__ to make an object unhashable (e.g., dicts). If so, this is a great addition. On Saturday, July 4, 2020 at 5:26:45 PM UTC-4, Joao S. O. Bueno wrote: > > > > On Sat, 4 Jul 2020 at 16:51, Serhiy Storchaka >

[Python-ideas] Re: Should use of _ as an R-value be deprecated?

2020-06-29 Thread Neil Girdhar
Oh, I guess there's gettext… On Monday, June 29, 2020 at 5:04:05 AM UTC-4, Neil Girdhar wrote: > > PEP 622 proposes a special use for _: to match anything, discarding the > whatever value matches. (If I understand.) This aligns with the way _ is > conventionally used in othe

[Python-ideas] Should use of _ as an R-value be deprecated?

2020-06-29 Thread Neil Girdhar
PEP 622 proposes a special use for _: to match anything, discarding the whatever value matches. (If I understand.) This aligns with the way _ is conventionally used in other statements. This special use in case statements feels weird given that _ is otherwise just an ordinary variable. It

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-06-28 Thread Neil Girdhar
Can you use SortedDict.peekitem(index): http://www.grantjenks.com/docs/sortedcontainers/sorteddict.html ? As other people are saying, the computational complexity of CPython's dict is linear for this operation. SortedDict does it in logarithmic time. On Friday, June 26, 2020 at 1:32:58 PM

[Python-ideas] Please consider adding numbers.Boolean

2020-06-21 Thread Neil Girdhar
I'm just curious if there was a reason why Boolean was omitted from the numeric tower in the numbers library? It seems that builtins.bool and numpy.bool_ would both be elements of Boolean, and Boolean itself would be Integral? Best, Neil ___

[Python-ideas] Re: Bringing the print statement back

2020-06-10 Thread Neil Girdhar
Nevertheless, it's nice to see how powerful the new parser is! Any chance this would allow us to have a multi-line with statement? with self.context_manager_one(some, parameters, that, are, passed) \ as return_value_one, \ self.context_manager_two(self.p, slice(None),

[Python-ideas] Re: Optional keyword arguments

2020-05-20 Thread Neil Girdhar
Have you seen PEP 505? https://www.python.org/dev/peps/pep-0505/ I'm still praying they add "??=" every time I need it. Maybe if someone proposed just that operator, it would go a long way towards simplifying code without resulting in endless debates? Best, Neil On Sunday, May 17, 2020 at

[Python-ideas] Re: PEP 618: Add Optional Length-Checking To zip

2020-05-20 Thread Neil Girdhar
I'm just curious, but is it usual for errors to be one-based rather than zero-based? If I do zip(*iterables, strict=True), then "argument 1 is too long" refers to iterables[0]? On Friday, May 1, 2020 at 2:20:12 PM UTC-4, Brandt Bucher wrote: > > I have pushed a first draft of PEP 618: > >

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

2020-04-15 Thread Neil Girdhar
I'm just curious: what is the downside of calling super with kwargs? Usually when I define a class, the first I write is def __init__(self, **kwargs): super().__init__(**kwargs) just in case I want to use the class in cooperative inheritance. I always thought it couldn't hurt? I might be

[Python-ideas] Should dataclass init call super?

2020-04-12 Thread Neil Girdhar
Dear Pythoners, class X: def __init__(self, x, **kwargs): super().__init__(**kwargs) print(x, kwargs) @dataclass class Y(X): y: int Y(1) # What should happen? Y(1, 2) # What should happen? I feel like it would be nice to be able to use dataclasses more often

[Python-ideas] Re: Add the imath module

2020-03-22 Thread Neil Girdhar
, March 22, 2020 at 2:01:18 PM UTC-4, Neil Girdhar wrote: > > I really like this idea. It fixes the weirdness whereby cmath is for > complex numbers, and math is for real numbers and integers. I like > separating them into three categories. > > One suggestion: Consider

[Python-ideas] Re: Add the imath module

2020-03-22 Thread Neil Girdhar
I really like this idea. It fixes the weirdness whereby cmath is for complex numbers, and math is for real numbers and integers. I like separating them into three categories. One suggestion: Consider generalizing binom to the multinomial coefficent. def binom(n, *ks): # Returns n! /

[Python-ideas] Re: Allow star unpacking within an slice expression

2020-03-06 Thread Neil Girdhar
Reviving this old thread since this is hitting me again today. Is there any momentum on extending tuple unpacking to within slices? On Thursday, December 21, 2017 at 4:33:07 PM UTC-5, Neil Girdhar wrote: > > I didn't think of this when we were discussing 448. I ran into this > to

[Python-ideas] Re: More descriptive error message than "too many values to unpack"

2020-03-06 Thread Neil Girdhar
I also would prefer richer exceptions especially if it can be done without introducing any other problems. In the same vein, I once suggested a richer inheritance failure message (this, basically: https://github.com/NeilGirdhar/inheritance_graph), for which if I remember correctly Guido was

[Python-ideas] Re: Traits

2020-02-14 Thread Neil Girdhar
You may be interested in the excellent traitlets library: https://traitlets.readthedocs.io/en/stable/ On Friday, February 7, 2020 at 11:11:59 AM UTC-5, Soni L. wrote: > > I'd like to see traits some day, with a syntax similar to this one: > > trait Trait: >def x(self): > raise

[Python-ideas] Re: Suggestion for language addition

2020-01-23 Thread Neil Girdhar
On Tuesday, December 3, 2019 at 7:54:03 PM UTC-5, Jan Bakuwel wrote: > > Hi Guido, > > On 4/12/19 1:06 pm, Guido van Rossum wrote: > > I was playing the devil's advocate in jest. There is no way this will > > be added to Python, for a large variety of sociological and software > >

[Python-ideas] Re: __repr__ helper(s) in reprlib

2020-01-23 Thread Neil Girdhar
I really like this feature suggestion and I would definitely use it if it were available. It might be easiest to have the repr helper do as much as it can, but give the user the flexibility to override things with varying levels of precision. For example: def kwargs(obj, keys:

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-03 Thread Neil Girdhar
This is very cool, well thought-out, and solves an important problem. I would have definitely benefited from Python having better pattern matching. As an idealist though, if you're going to add pattern matching, why not just do it completely? I agree that your proposal would be useful in some

[Python-ideas] Re: Fix statistics.median()?

2019-12-29 Thread Neil Girdhar
I'm just glancing at this thread, but it sounds like you want to add the quickselect algorithm to the standard library. As you point out in another message, quickselect is faster than quicksort: it is linear time (provided the pivot is chosen by median of medians) whereas quicksort is

[Python-ideas] Re: Using 'with' with extra brackets for nicer indentation

2019-11-19 Thread Neil Girdhar
On Tuesday, November 19, 2019 at 3:06:26 PM UTC-5, Paul Moore wrote: > > On Tue, 19 Nov 2019 at 19:03, Random832 > wrote: > > > > On Tue, Nov 19, 2019, at 11:26, Paul Moore wrote: > > > Because you don't have to create the context manager directly in the > > > with statement > > > >

[Python-ideas] Consider blocking heterogeneous chained comparison

2019-11-17 Thread Neil Girdhar
Some people find this legal syntax confusing: A in B < C (It means A in B and B < C.) I feel like most code reviews would not allow this kind of code to be checked in, at least without a comment explaining what the code does. What are the motivating reasons for allowing this syntax? Is

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-22 Thread Neil Girdhar
I really like this idea. Once you've already decided to raise an exception, does it really cost much to try to raise a more helpful one? And helpful exception messages make programming a lot less painful, and a lot more of a joy. On Tue, Oct 22, 2019 at 2:43 PM Mike Miller wrote: > > On

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-21 Thread Neil Girdhar
I would use it, and I prefer | for the reasons given by Stephen, MRAB, and the other proponents. On Monday, October 21, 2019 at 1:08:32 AM UTC-4, Andrew Barnert via Python-ideas wrote: > > On Oct 20, 2019, at 21:10, Stephen J. Turnbull < > turnbull...@u.tsukuba.ac.jp > wrote: > > > > I'm not

[Python-ideas] Re: Add Subscriptable ABC

2019-10-11 Thread Neil Girdhar
On Fri., Oct. 11, 2019, 2:38 a.m. Neil Girdhar, wrote: > > > On Fri, Oct 11, 2019 at 2:28 AM Andrew Barnert wrote: > >> > On Oct 10, 2019, at 22:13, Neil Girdhar wrote: >> > >> > That's funny, I always thought of that as legacy. The iterator >>

[Python-ideas] Re: Add Subscriptable ABC

2019-10-10 Thread Neil Girdhar
On Monday, September 30, 2019 at 12:24:30 AM UTC-4, Andrew Barnert via Python-ideas wrote: > > On Sep 29, 2019, at 16:41, Steven D'Aprano > wrote: > > > >> On Sun, Sep 29, 2019 at 11:27:32AM +0100, Oscar Benjamin wrote: > >> > >> That's the point that I would make as well. What can you do

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

2019-09-19 Thread Neil Girdhar
I think I agree with Serhiy, but I don't think Anders' suggestion is workable since it's very common in __init__.py to do exactly this (import * from local modules in order to re-export them), and you definitely don't want to explitly foo=foo for everything. That's the whole reason you

[Python-ideas] Re: PEP-603: Adding a frozenmap type to collections

2019-09-12 Thread Neil Girdhar
I'll let other people comment on this wrt Python (even though I think it looks cool and useful to me). Out of curiosity, why does frozenmap not have the same runtime and ordering guarantees as dict? On Thursday, September 12, 2019 at 7:47:25 AM UTC-4, Yury Selivanov wrote: > > Hi! > > I've

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-08-09 Thread Neil Girdhar
The documentation is beautiful. One of the features I was looking for when evaluating parsers was the ability to run expression on the rules. For example if you matching "\begin{\w*}" and \w* turns out to be "enumeration", then later when you match "\end{\w*}" then you want to check that that

[Python-ideas] Integer infinity and extended integers

2019-06-24 Thread Neil Girdhar
Now that Python is beginning to embrace type annotations, is it worth revisiting the idea of having extended integers and an integer infinity? I found myself trying to annotate this line: events_to_do: Union[int, float] = math.inf where I am only including float in the union to accommodate

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

2019-03-04 Thread Neil Girdhar
On Mon, Mar 4, 2019 at 3:58 PM Christopher Barker wrote: > > > > On Mon, Mar 4, 2019 at 12:41 PM Guido van Rossum wrote: >> >> Honestly I would rather withdraw the subtraction operators than reopen the >> discussion about making dict more like set. I think that's unfortunate. > > > +1 > > I

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

2019-03-04 Thread Neil Girdhar
On Mon, Mar 4, 2019 at 3:22 PM Guido van Rossum wrote: > > On Mon, Mar 4, 2019 at 12:12 PM Neil Girdhar wrote: >> >> On Mon, Mar 4, 2019 at 2:26 PM Guido van Rossum wrote: >> > >> > * Dicts are not like sets because the ordering operators (<, &l

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

2019-03-04 Thread Neil Girdhar
On Mon, Mar 4, 2019 at 2:26 PM Guido van Rossum wrote: > > * Dicts are not like sets because the ordering operators (<, <=, >, >=) are > not defined on dicts, but they implement subset comparisons for sets. I think > this is another argument pleading against | as the operator to combine two >

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

2019-03-01 Thread Neil Girdhar
I think that sequence should be fixed. On Fri., Mar. 1, 2019, 7:12 p.m. Brandt Bucher, wrote: > While working through my implementation, I've come across a couple of > inconsistencies with the current proposal: > > > The merge operator will have the same relationship to the dict.update > method

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

2019-03-01 Thread Neil Girdhar
Looks like a good start. I think you should replace all of the lines: if isinstance(other, dict): with if isinstance(self, type(other)): Since if other is an instance of a dict subclass, he should be the one to process the addition. On the other hand, if self is an instance of the derived

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

2019-03-01 Thread Neil Girdhar
On Friday, March 1, 2019 at 5:47:06 AM UTC-5, Steven D'Aprano wrote: > > On Fri, Mar 01, 2019 at 08:47:36AM +0200, Serhiy Storchaka wrote: > > > Currently Counter += dict works and Counter + dict is an error. With > > this change Counter + dict will return a value, but it will be different >

Re: [Python-ideas] Please consider adding an overrideable flag to abstractmethod

2019-02-17 Thread Neil Girdhar
eable", and could be exposed in abc. When used in combination with @abstractmethod, it could have the above behavior. On Sunday, February 17, 2019 at 5:28:49 AM UTC-5, Neil Girdhar wrote: > > Marking a method M declared in C with abstractmethod indicates that M > needs to be *implemented

[Python-ideas] Please consider adding an overrideable flag to abstractmethod

2019-02-17 Thread Neil Girdhar
Marking a method M declared in C with abstractmethod indicates that M needs to be *implemented* in any subclass D of C for D to be instantiated. We usually think of overriding a method N to mean replacing one implementation in some class E with another in some subclass of E, F. Often, the

Re: [Python-ideas] NAN handling in the statistics module

2019-01-10 Thread Neil Girdhar
On Monday, January 7, 2019 at 3:16:07 AM UTC-5, Steven D'Aprano wrote: > > (By the way, I'm not outright disagreeing with you, I'm trying to weigh > up the pros and cons of your position. You've given me a lot to think > about. More below.) > > On Sun, Jan 06, 2019 at 11:31:30PM -0800,

Re: [Python-ideas] async unittest.TestCase

2018-10-29 Thread Neil Girdhar
Why not just use pytest? On Wednesday, October 10, 2018 at 7:12:02 AM UTC-4, David Shawley wrote: > > Hi everyone and good morning to some of you, > > Since asyncio and the async/await syntax are both part of Python, I think > that we should extend TestCase to support it. The simplest solution

Re: [Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?

2018-09-03 Thread Neil Girdhar
I prefer Python's syntax. In the Keras example, Python pays off compared to the XML or YAML or whatever as soon as you need to define something programmatically. For example, if your model is generated based on some other input. Anyway, most of your time is not spent typing punctuation.

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-31 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 9:03 AM Steven D'Aprano wrote: > On Wed, Aug 29, 2018 at 09:39:05PM -0700, Neil Girdhar wrote: > > > Would there be any problem with changing: > > > > In [4]: Fraction(1, 1) ** Fraction(2, 3) > > Out[4]: 1.0 > > > > In [5]: F

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
Hey, no worries. I do think though that people should feel free to suggest ideas even if they have never contributed anything. I read python-ideas for the discussion. Thank you for your feedback about my suggestion. On Thu, Aug 30, 2018 at 8:18 AM Jonathan Fine wrote: > Hi Neil > > When I

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
Yeah, you're right, my original mail was posted on google groups. Sorry for the trouble. On Thu, Aug 30, 2018 at 8:15 AM Paul Moore wrote: > Thu, 30 Aug 2018 at 12:55, Neil Girdhar wrote: > > > > On Thu, Aug 30, 2018 at 7:13 AM Paul Moore wrote: > >> > >> (

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
using google groups. I'm only replying to the emails that are sent to me. I guess gmail's reply-all is gathering the google groups mail from the thread. > On Thu, 30 Aug 2018 at 11:28, Neil Girdhar wrote: > > > > But I'm only asking for fractional powers of -1, 0, and 1. Is that > r

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 7:03 AM Jonathan Fine wrote: > Hi Neil > > Summary: You say something should be done. But by who? Perhaps the > should starts with you. > What does this mean? Are you asking who is going to do the implementation? I posted here to get feedback about whether it would be

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
Thanks for the feedback. On Thu, Aug 30, 2018 at 7:13 AM Paul Moore wrote: > (You're still not fixing your mail headers. Please do, it's hard to be > bothered responding if I keep having to fix your mails in order to do > so). > > On Thu, 30 Aug 2018 at 11:28, Neil

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 5:51 AM Nicolas Rolin wrote: > > > >>> Right, but we already have some special cases: >> >> In [8]: Fraction(2, 3) ** Fraction(3, 1) >> Out[8]: Fraction(8, 27) >> >> Fraction.__pow__ already tries to return Fraction objects where possible. >> > > > I think the main point

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 5:27 AM Greg Ewing wrote: > Neil Girdhar wrote: > > we want branch continuity in the power. > > After all, floating point values have some inaccuracy, and we wouldn't > > want chaotic behavior, i.e., small changes to the power to have drastic >

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 5:11 AM Jonathan Fine wrote: > Hi Neil > > We wrote > > >> This gives the same results as Python's Fraction, except for your > >> example [6]. There, it gives the Fraction(0) you ask for. > >> > >> If the smart mathematicians and computer scientists that wrote gp/pari >

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 4:38 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Neil Girdhar writes: > > > There are a lot of misunderstandings in this thread. It's probably > > best to start by reading up on the roots of unity ( > >

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 4:01 AM Paul Moore wrote: > On Thu, 30 Aug 2018 at 08:38, Neil Girdhar wrote: > > > > There are a lot of misunderstandings in this thread. It's probably best > to start by reading up on the roots of unity ( > https://en.wikipedia.org/wiki/Root_of_u

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
There are a lot of misunderstandings in this thread. It's probably best to start by reading up on the roots of unity ( https://en.wikipedia.org/wiki/Root_of_unity). The key ideas are that a real number has two complex square roots, three complex cube roots, and so on. Normally, in Python, we

Re: [Python-ideas] Fix some special cases in Fractions?

2018-08-30 Thread Neil Girdhar
On Thu, Aug 30, 2018 at 2:09 AM Greg Ewing wrote: > Jeroen Demeyer wrote: > > On 2018-08-30 06:39, Neil Girdhar wrote: > > > >> I'd like these to be Fraction(1), Fraction(1), and Fraction(0). > > > > Why? I cannot think of any natural use case why you would

[Python-ideas] Fix some special cases in Fractions?

2018-08-29 Thread Neil Girdhar
Would there be any problem with changing: In [4]: Fraction(1, 1) ** Fraction(2, 3) Out[4]: 1.0 In [5]: Fraction(-1, 1) ** Fraction(2, 3) Out[5]: (-0.4998+0.8660254037844387j) In [6]: Fraction(0, 1) ** Fraction(2, 3) Out[6]: 0.0 I'd like these to be Fraction(1), Fraction(1), and

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-16 Thread Neil Girdhar
Is None a builtin? In [1]: from keyword import kwlist In [3]: 'Ellipsis' in kwlist Out[3]: False In [4]: 'None' in kwlist Out[4]: True Maybe we should change This type has a single value. There is a single object with this value. This object is accessed through the built-in name None. It is

Re: [Python-ideas] Reminder about intent of messages (Was: Syntactic sugar to declare partial functions)

2018-08-12 Thread Neil Girdhar
significant, and non-trivial. >> >> What, exactly, is the difference between "minor" and "non-trivial" and >> when did I say the harm was "significant and non-trivial"? >> >> [Alex Walters] >> >>> You will find no evidence

Re: [Python-ideas] Is this PEP-able? "with" statement inside genexps / list comprehensions

2018-08-11 Thread Neil Girdhar
On Monday, July 30, 2018 at 3:55:25 PM UTC-4, Kyle Lahnakoski wrote: > > Rudy, > > I think your proposal may be very specific to iterable context managers; > I don't think his proposal is specific to iterable context managers. You can have a with clause that is used in a following for clause.

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

2018-08-11 Thread Neil Girdhar
My only motivation for this idea is so that I can forget about namedtuple. Thinking about it again today, I withdraw my suggestion until I one day see a need for it. On Fri, Aug 10, 2018 at 10:14 PM Eric V. Smith wrote: > On 8/10/2018 7:01 PM, Neil Girdhar wrote: > > It woul

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

2018-08-10 Thread Neil Girdhar
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 namedtuple. It would almost totally supplant it

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-10 Thread Neil Girdhar
On Fri, Aug 10, 2018 at 6:21 PM Abe Dillon wrote: > [Neil Girdhar] > > I prefer partial since many programmers studied computer science > > > Many did not. I studied electrical engineering and wouldn't have been able > to tell you what the word 'partial' meant four years

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-09 Thread Neil Girdhar
ssion, but I > think they would (or do in the case of 'lambda') harm Python. I know the > correct term for the 'if-else' expression is a 'ternary' expression, but > that doesn't mean Python should have used the word 'ternary' in the syntax. > > On Thu, Aug 9, 2018 at 12:14 PM, Neil Gi

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-09 Thread Neil Girdhar
That's a nicer solution to me. On Thu, Aug 9, 2018 at 1:00 PM Michel Desmoulin wrote: > I'd rather have functools.partial() to be added as a new method on > function objects. > > > > > fromfunctools importpartial > > > > > > def add(x:int,y:int)->int: > > returnx +y > > > > > > add_2 =

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Neil Girdhar
omplicated for a small fraction of users. There will always be a gap between Python and symbolic equation generation. On Mon, Aug 6, 2018 at 9:03 PM Steven D'Aprano wrote: > On Mon, Aug 06, 2018 at 02:44:24PM -0700, Neil Girdhar wrote: > > > This doesn't work because the logical Boolean o

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-06 Thread Neil Girdhar
By the way, these are not "partial functions", and shouldn't be called that. These are "partial function applications". On Saturday, August 4, 2018 at 12:03:50 PM UTC-4, Fabrizio Messina wrote: > > > Hello, I would like to propose a new method to create a partial function. > > At the moment

  1   2   3   >