[issue46757] dataclasses should define an empty __post_init__

2022-02-22 Thread Neil Girdhar
Neil Girdhar added the comment: @eric Good thinking. Would it make sense to add to the documentation as well that the __post_init__ methods aren't collected, and you should call super's __post_init__ if there is one using something like if hasattr(super(), "__post_i

[issue46757] dataclasses should define an empty __post_init__

2022-02-21 Thread Neil Girdhar
Neil Girdhar added the comment: @Raymond yeah I've been thinking about this some more, and there's no way to have a "top level" method with the dataclass decorator. I think I will make a case to have a class version of dataclasses that works with inheritance. Class versions of d

[issue46757] dataclasses should define an empty __post_init__

2022-02-20 Thread Neil Girdhar
Neil Girdhar added the comment: > How would an arbitrary derived class know how to call this? It can't. There > has to be knowledge of the base class's requirements already. Surely knowing > "__post_init__ must be called with some_arg" isn't too different from "

[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Neil Girdhar
Neil Girdhar added the comment: > I'm not crazy about adding a method to every dataclass just for the 0.1% of > the times it's needed. I'm not sure I totally understand the cost here. You can have a single shared global function that you set on each dataclass. So the only cost

[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Neil Girdhar
Neil Girdhar added the comment: On Sat, Feb 19, 2022 at 2:51 AM Vedran Čačić wrote: > > Vedran Čačić added the comment: > > That "except AttributeError" approach is a powerful bug magnet, since it > can very easily mask real attribute errors stemming from mis

[issue46757] dataclasses should define an empty __post_init__

2022-02-15 Thread Neil Girdhar
New submission from Neil Girdhar : When defining a dataclass, it's possible to define a post-init (__post_init__) method to, for example, verify contracts. Sometimes, when you inherit from another dataclass, that dataclass has its own post-init method. If you want that method to also do its

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

2022-02-12 Thread Neil Girdhar
Neil Girdhar added the comment: Thank you, this would have saved me a lot of time! On Sat, Feb 12, 2022 at 8:37 PM Alexander wrote: > > Alexander added the comment: > > Indeed, the error message does not help to identify the problem. Moreover, > it collides with

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

2022-02-12 Thread Neil Girdhar
New submission from Neil Girdhar : 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

[issue23316] Incorrect evaluation order of function arguments with *args

2021-06-16 Thread Neil Girdhar
Neil Girdhar added the comment: FYI: https://github.com/PyCQA/pylint/issues/4586 -- ___ Python tracker <https://bugs.python.org/issue23316> ___ ___ Python-bug

[issue4356] Add "key" argument to "bisect" module functions

2019-05-26 Thread Neil Girdhar
Neil Girdhar added the comment: The problem with `key=lambda item: -item` is that item cannot always be easily negated. For example, tuples are often used as keys. -- ___ Python tracker <https://bugs.python.org/issue4

[issue34363] dataclasses.asdict() mishandles dataclass instance attributes that are instances of subclassed typing.NamedTuple

2018-08-10 Thread Neil Girdhar
Neil Girdhar added the comment: > The code generated by oollections.namedtuple was based on patterns already in > widespread use at the time. That's fair enough. However, it seems like there is one important difference: unlike any other Sequence, namedtuples cannot be initi

[issue34363] dataclasses.asdict() mishandles dataclass instance attributes that are instances of subclassed typing.NamedTuple

2018-08-10 Thread Neil Girdhar
Neil Girdhar added the comment: Why can't we add an ABC into a NamedTuple instance's MRO? Because while I like Eric's solution, it seems to be backwards: tuple and list are not the special cases—NamedTuple is. All sequences accept an iterable in their constructor, and NamedTuple doesn't

[issue34363] dataclasses.asdict() mishandles dataclass instance attributes that are instances of subclassed typing.NamedTuple

2018-08-09 Thread Neil Girdhar
Neil Girdhar added the comment: Sorry if I'm intruding here, but I really dislike that we are doing isinstance versus list, tuple, and dict. And I dislike even more type(x) in (list, tuple). I think the ideal thing to do would have been to check versus abstract base classes like

[issue33419] Add functools.partialclass

2018-05-09 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: It seems like Python doesn't do very well with dynamically-generated classes. For that reason, I'm losing interest on this feature. Is there any interest in merging the documentation changes here: https://bugs.python.org/review

[issue33419] Add functools.partialclass

2018-05-04 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: I'm not sure that this should be in the stdlib. The three-line function can be enough for your simple case, and it is too simple for including it in the stdlib. But for general stdlib quality solution it lacks many details. 1. It d

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: Done: https://github.com/python/cpython/pull/6699 -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: I figured it would have to be 3.8, but it looks like Doc/whatsnew/3.8.rst has not been created? Do I create that? -- ___ Python tracker <rep...@bugs.python.org> <https://

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Change by Neil Girdhar <mistersh...@gmail.com>: Added file: https://bugs.python.org/file47569/partialclass3.diff ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: Added functools experts. Links to relevant stackoverflow questions: https://stackoverflow.com/questions/38911146/python-equivalent-of-functools-partial-for-a-class-constructor https://stackoverflow.com/questions/50143864/is-there-

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: I edited some of the documentation as well to use the technical terms "partial function application", "partial method application", and "partial class application". This emphasizes the para

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Change by Neil Girdhar <mistersh...@gmail.com>: Added file: https://bugs.python.org/file47568/partialclass2.diff ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
Change by Neil Girdhar <mistersh...@gmail.com>: -- components: +Library (Lib) type: -> enhancement ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue33419] Add functools.partialclass

2018-05-03 Thread Neil Girdhar
New submission from Neil Girdhar <mistersh...@gmail.com>: functools.partial is almost good enough for specifying some of the parameters of an object's initializer, but the partial object doesn't respond properly to issubclass. Adding functools.partialclass is similar to the ad

[issue32626] Subscript unpacking raises SyntaxError

2018-01-27 Thread Neil Girdhar
Neil Girdhar <mistersh...@gmail.com> added the comment: This came up already on python-ideas: https://groups.google.com/forum/#!topic/python-ideas/YOpT9fDQyFk I think this was an oversight, and I'm with Ben that it's unexpected. That said, this is usually the kind of thing that Guido

[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Neil Girdhar
Neil Girdhar added the comment: Okay, I understand what you're saying, but I it says in the documentation that "if an explicit metaclass is given and it is not an instance of type(), then it is used directly as the metaclass". My recent updated "metaclass_callable" is not

[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Neil Girdhar
Neil Girdhar added the comment: Thanks for taking the time to explain, but it's still not working for me: from types import new_class class MyMetaclass(type): pass class OtherMetaclass(type): pass def metaclass_callable(name, bases, namespace): return new_class(name, bases, dict

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: "As a result of this, *both* implementations include a conditional check for a more derived metaclass in their namespace preparation logic, as well as an unconditional call to that metaclass derivation logic from type_new if the calculated metaclass is e

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: >From your comment: >>> MyDerivedDynamic = new_class("MyDerivedDynamic", (MyClass,), >>> dict(metaclass=metaclass_callable)) Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.5/ty

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: The documentation suggests that you can have a metaclass that does is not the "most derived metaclass" provided you specify one that is not an instance of type. This doesn't work in CPython, so I would suggest fixing the documentation using the text

[issue28437] Class definition is not consistent with types.new_class

2016-10-13 Thread Neil Girdhar
Neil Girdhar added the comment: Oops, I meant: MyDerived = new_class("MyDerived", (MyClass,), dict(metaclass=metaclass_callable)) Nevertheless, the exception line number is totally off because it's tripping in the C code rather than in the Python code of the typ

[issue28437] Class definition is not consistent with types.new_class

2016-10-13 Thread Neil Girdhar
New submission from Neil Girdhar: Minimum working example: class MyMetaclass(type): pass class OtherMetaclass(type): pass def metaclass_callable(name, bases, namespace): return OtherMetaclass(name, bases, namespace) class MyClass(metaclass=MyMetaclass): pass try: class

[issue27598] Add Collection to collections.abc and typing

2016-08-19 Thread Neil Girdhar
Neil Girdhar added the comment: (never mind about the comparison operators :) Turns out that would break backwards compatibility.) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue27802] Add __eq__ and __ne__ to collections.abc.Sequence.

2016-08-19 Thread Neil Girdhar
Neil Girdhar added the comment: (there's already an open thread.) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27802> ___ ___

[issue27802] Add __eq__ and __ne__ to collections.abc.Sequence.

2016-08-19 Thread Neil Girdhar
Neil Girdhar added the comment: That's a really good point. Perhaps bring it up on ideas so that it can be discussed by more people? I don't know what the answer is. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue27598] Add Collection to collections.abc and typing

2016-08-19 Thread Neil Girdhar
Changes by Neil Girdhar <mistersh...@gmail.com>: -- title: Add SizedIterable to collections.abc and typing -> Add Collection to collections.abc and typing ___ Python tracker <rep...@bugs.python.org> <http://bugs.pyt

[issue27598] Add SizedIterable to collections.abc and typing

2016-08-19 Thread Neil Girdhar
Neil Girdhar added the comment: Given issue http://bugs.python.org/issue27802, it might be worth considering that all Collections implement __eq__ and __ne__, so maybe these should be abstract methods on Collection? -- ___ Python tracker <

[issue27802] Add __eq__ and __ne__ to collections.abc.Sequence.

2016-08-19 Thread Neil Girdhar
Changes by Neil Girdhar <mistersh...@gmail.com>: -- keywords: +patch Added file: http://bugs.python.org/file44151/abc_eq.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27802] Add __eq__ and __ne__ to collections.abc.Sequence.

2016-08-19 Thread Neil Girdhar
Changes by Neil Girdhar <mistersh...@gmail.com>: -- components: +Library (Lib) versions: +Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27802] Add __eq__ and __ne__ to collections.abc.Sequence.

2016-08-19 Thread Neil Girdhar
New submission from Neil Girdhar: Both Mapping and Set provide __eq__ and __ne__. Why not have Sequence do the same? -- messages: 273114 nosy: neil.g priority: normal severity: normal status: open title: Add __eq__ and __ne__ to collections.abc.Sequence

[issue27598] Add SizedIterable to collections.abc and typing

2016-08-19 Thread Neil Girdhar
Neil Girdhar added the comment: (added the documentation changes) -- Added file: http://bugs.python.org/file44146/doc_changes.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Neil Girdhar
Neil Girdhar added the comment: Great patch. Shouldn't Sequence be a "Reversible, Collection"? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.py

[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Neil Girdhar
Neil Girdhar added the comment: @gvanrossum is there any reason that subclasshook is implemented by overriding instead of cooperation? E.g.,: class Sized(metaclass=ABCMeta): @classmethod def __subclasshook__(cls, C): return (super().__subclasshook__(C

[issue26020] set_display evaluation order doesn't match documented behaviour

2016-04-26 Thread Neil Girdhar
Neil Girdhar added the comment: Ah, sorry, I somehow went cross-eyed. Not sure offhand which test would test the BUILD_TUPLE_UNPACK, but I think you're right Serhiy. Could just add both? -- ___ Python tracker <rep...@bugs.python.org>

[issue26020] set_display evaluation order doesn't match documented behaviour

2016-04-26 Thread Neil Girdhar
Neil Girdhar added the comment: Please don't forget to fix BUILD_SET_UNPACK to match. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue26020] set_display evaluation order doesn't match documented behaviour

2016-04-26 Thread Neil Girdhar
Neil Girdhar added the comment: Also, please add the following test: "{*{True, 1}}" Should be True. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.py

[issue4356] Add "key" argument to "bisect" module functions

2016-02-29 Thread Neil Girdhar
Neil Girdhar added the comment: I'm also looking for bisect with a key argument (numpy array of records, want to search on one element). However, I don't see bisect in the what's new: https://docs.python.org/3.6/whatsnew/3.6.html ? Any luck with the implementation? -- nosy: +neil.g

[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-13 Thread Neil Girdhar
Neil Girdhar added the comment: Ah, good point. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24624 ___ ___ Python-bugs-list mailing list

[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-12 Thread Neil Girdhar
New submission from Neil Girdhar: In the description of the consume recipe: def consume(iterator, n): Advance the iterator n-steps ahead. If n is none, consume entirely. # Use functions that consume iterators at C speed. if n is None: # feed the entire iterator into a zero

[issue24136] document PEP 448: unpacking generalization

2015-07-09 Thread Neil Girdhar
Neil Girdhar added the comment: Copied from closed issue 24240: Since Grammar/Grammar relies on semantic postprocessing in ast.c, it would be nice to have an update of the (human readable) Grammar in the language reference docs. -- ___ Python

[issue24136] document PEP 448: unpacking generalization

2015-07-07 Thread Neil Girdhar
Neil Girdhar added the comment: I don't receive emails from the tracker anymore either and I have no idea why that is. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24136

[issue24136] document PEP 448

2015-05-29 Thread Neil Girdhar
Neil Girdhar added the comment: Simplified functools.partial documentation. -- Added file: http://bugs.python.org/file39561/wn2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24136

[issue24136] document PEP 448

2015-05-29 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file39562/wn2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24136

[issue24136] document PEP 448

2015-05-14 Thread Neil Girdhar
Neil Girdhar added the comment: Just updated the what's new. Also, thank you for adding my name to Misc/Acks. Should we also add Joshua Landau's name? He helped me quite a bit with the implementation, and he wrote the PEP. -- keywords: +patch nosy: +neil.g Added file: http

[issue2292] Missing *-unpacking generalizations

2015-04-28 Thread Neil Girdhar
Neil Girdhar added the comment: All tests pass. All reviewer comments addressed. Please let me know if anything else needs to be done from my end. -- Added file: http://bugs.python.org/file39230/starunpack42.diff ___ Python tracker rep

[issue2292] Missing *-unpacking generalizations

2015-04-28 Thread Neil Girdhar
Neil Girdhar added the comment: Hi Steve: I have limited expertise in most of these areas, but I looked at starunpack40.diff and have these comments: * tests look to have good coverage of the feature (can't speak to coverage of the parser/compiler code) * parsermodule.c changes comprehension

[issue2292] Missing *-unpacking generalizations

2015-04-15 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file39059/starunpack41.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-04-07 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file38856/starunpack40.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-03-20 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file38611/starunpack38.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-03-20 Thread Neil Girdhar
Neil Girdhar added the comment: Removed a confusing and outdated comment in Lib/importlib/_bootstrap.py -- Added file: http://bugs.python.org/file38613/starunpack39.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-03-12 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file38429/starunpack37.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-03-08 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file38395/starunpack36.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue22906] PEP 479: Change StopIteration handling inside generators

2015-03-05 Thread Neil Girdhar
Neil Girdhar added the comment: FWIW I looked at the changes. Does it make sense to run tests before there are actual tests in lib/Test? I'll happily run all tests when some new ones are added. -- nosy: +neil.g ___ Python tracker rep

[issue2292] Missing *-unpacking generalizations

2015-03-05 Thread Neil Girdhar
Neil Girdhar added the comment: Removed dead code. Awaiting code review! :) -- Added file: http://bugs.python.org/file38341/starunpack35.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue23595] Split the math module into _math (C) + math (py)

2015-03-05 Thread Neil Girdhar
Neil Girdhar added the comment: Nice work Alexander. I believe what's left is for it to work with complex numbers. -- nosy: +neil.g ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23595

[issue2292] Missing *-unpacking generalizations

2015-02-26 Thread Neil Girdhar
Neil Girdhar added the comment: New changelist for updated patch (before merging changes). -- Added file: http://bugs.python.org/file38252/starunpack33.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-02-26 Thread Neil Girdhar
Neil Girdhar added the comment: Finished merge. -- Added file: http://bugs.python.org/file38253/starunpack34.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-02-09 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file38062/starunpack31.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-02-09 Thread Neil Girdhar
Neil Girdhar added the comment: Thank you, Benjamin. It's my nature to keep code consistent/clean, but I realize that I can get carried away. Should I revert all incidental PEP 7 style changes? Regarding the args/keywords, where do you mean? If you're talking about compile.c, we can't

[issue2292] Missing *-unpacking generalizations

2015-02-09 Thread Neil Girdhar
Neil Girdhar added the comment: Removed incidental PEP 7 changes and reran tests. -- Added file: http://bugs.python.org/file38070/starunpack32.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Neil Girdhar added the comment: Another bug, another test. -- Added file: http://bugs.python.org/file37926/starunpack29.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Neil Girdhar added the comment: Fixed a bug in ceval.c; added a test to test_unpack_ex. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37924/starunpack28.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37925/starunpack28.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Removed file: http://bugs.python.org/file37924/starunpack28.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Neil Girdhar added the comment: Ready for a code review: Blocked f(*x for x…) as requested. Polished up parsermodule.c. -- Added file: http://bugs.python.org/file37920/starunpack26.diff ___ Python tracker rep...@bugs.python.org http

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Neil Girdhar added the comment: Is it possible to edit the PEP to reflect the current design decisions? Specifically: * Remove: Because of the new levity for * and ** unpackings, it may be advisable to lift some or all of these restrictions. (in both abstract and specification) * Extend

[issue2292] Missing *-unpacking generalizations

2015-01-30 Thread Neil Girdhar
Neil Girdhar added the comment: Fixed a bug and added a test. -- Added file: http://bugs.python.org/file37921/starunpack27.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-29 Thread Neil Girdhar
Neil Girdhar added the comment: All tests pass. @Guido: can we get some clarification on f(*… and f(**…? One option is to make them illegal for now and then open them up in a future PEP when it's more clear what's wanted? -- Added file: http://bugs.python.org/file37911/starunpack25

[issue2292] Missing *-unpacking generalizations

2015-01-28 Thread Neil Girdhar
Neil Girdhar added the comment: Fixed a couple bugs and added a test. Incremented the magic number. -- Added file: http://bugs.python.org/file37896/starunpack24.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-28 Thread Neil Girdhar
Neil Girdhar added the comment: Just need to fix the parser now. Minimal example: parser.sequence2st(parser.expr({1}).totuple()) Traceback (most recent call last): File stdin, line 1, in module parser.ParserError: Expected node type 12, got 302

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: def f(a, *b): print(list(a), list(b)) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: Is this correct? f(*i for i in ['abc', 'def']) ['a', 'b', 'c', 'd', 'e', 'f'] [] f(**i for i in ['abc', 'def']) File stdin, line 1 f(**i for i in ['abc', 'def']) ^ SyntaxError: invalid syntax Should neither work? Both

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: After thinking about this a bit more, my suggestion is not to fix it. Instead, I suggest that PEP 8 be modified to suggest that all positional arguments and iterable argument unpackings precede keyword arguments and keyword argument unpackings. Then, a tool

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: (I also suggest that the evaluation order within a function argument list to be defined to be positional and iterable before keyword, otherwise left-to-right —  rather than strictly left-to-right). -- ___ Python

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: Could you help me understand this a bit better? I always thought of f(x for x in l) as equivalent to f( (x for x in l) ). So, I can see that f(*x for x in l) should be equivalent to f( (*x for x in l) ). How should we interpret f(**x for x in l)? Is it then f

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: Everything seems to work except two tests are still failing: parser and venv. Any ideas Joshua? Also, we have to decide what to do with f(*x for x in l) and f(**x for x in l). -- Added file: http://bugs.python.org/file37877/starunpack23.diff

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37876/starunpack22.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-26 Thread Neil Girdhar
Neil Girdhar added the comment: fixed a minor bug with the function address, and made a number of polishing changes. -- Added file: http://bugs.python.org/file37871/starunpack21.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue2292] Missing *-unpacking generalizations

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: Fixed all tests except test_parser. New node numbers are not reflected here for some reason. -- Added file: http://bugs.python.org/file37854/starunpack18.diff ___ Python tracker rep...@bugs.python.org http

[issue2292] Missing *-unpacking generalizations

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: Dict comprehensions work. -- Added file: http://bugs.python.org/file37852/starunpack16.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: actually, we accept alternation, so maybe a bit to say whether we start with a list or a dict followed by a length of the alternating sequence? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: Yes, sorry David. I got linked here from the other issue. In any case, in the current code, the longest alternating sequence possible is 4. So one way to solve this is to change the CALL_FUNCTION parameters to be lists and dicts only and then process

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: another option is to add a LIST_EXTEND(stack_difference) opcode that would allow us to take the late iterable and extend a list at some arbitrary stack position. I had to add something like that for dicts for the other issue, so it would follow that pattern

[issue2292] Missing *-unpacking generalizations

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: Dict displays work. -- Added file: http://bugs.python.org/file37851/starunpack15.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: All tests pass, polishing. Joshua, I'm still not sure how to do show the right error for the function call with duplicate arguments… -- Added file: http://bugs.python.org/file37853/starunpack17.diff ___ Python

[issue23316] Incorrect evaluation order of function arguments with *args

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: I assume this is the problem: dis.dis('f(*a(), b=b())') 1 0 LOAD_NAME0 (f) 3 LOAD_NAME1 (a) 6 CALL_FUNCTION0 (0 positional, 0 keyword pair) 9 LOAD_CONST

[issue2292] Missing *-unpacking generalizations

2015-01-25 Thread Neil Girdhar
Neil Girdhar added the comment: Sounds good. I'll stop working until I see your patch. I tried to make it easy for you to implement your error idea wrt BUILD_MAP_UNPACK :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue2292] Missing *-unpacking generalizations

2015-01-22 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37821/starunpack14.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-22 Thread Neil Girdhar
Changes by Neil Girdhar mistersh...@gmail.com: Removed file: http://bugs.python.org/file37817/starunpack14.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292

[issue2292] Missing *-unpacking generalizations

2015-01-22 Thread Neil Girdhar
Neil Girdhar added the comment: By the way, Joshua if you wanted to edit the text of the PEP, it might be nice to point out that this replaces itertools.chain.from_iterable. I know you mention one use of itertools.chain, but I think this nicely replaces all uses of both: itertools.chain(a, b

  1   2   >