Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Greg Ewing
John Arbash Meinel wrote: Because you wouldn't want to have A.echo() Say that it takes 1 argument and (-1 given) ? Something like 1 argument in addition to 'self' would be reasonably clear and would cover both situations. +1 on fixing this from me, too. Even when you understand exactly

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Ben Finney
Greg Ewing greg.ew...@canterbury.ac.nz writes: John Arbash Meinel wrote: Because you wouldn't want to have A.echo() Say that it takes 1 argument and (-1 given) ? Something like 1 argument in addition to 'self' would be reasonably clear and would cover both situations. Except that

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Floris Bruynooghe
On Thu, May 20, 2010 at 11:55:02AM +0900, Stephen J. Turnbull wrote: Giampaolo Rodolà writes: class A: ... def echo(self, x): ... return x ... a = A() a.echo() Traceback (most recent call last): File stdin, line 1, in module TypeError: echo() takes

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Hi, Guido. On Wed, May 19, 2010 at 12:11 AM, Guido van Rossum gu...@python.org wrote: This is typically called a bag. Maybe searching for that will help you find a recipe? A bag/multiset is close to what I need, except for one thing: I need to iterate over the elements in the original order,

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Hello, Oleg. class UnorderedList(list): def __eq__(self, other): if not isinstance(other, UnorderedList): return False return sorted(self) == sorted(other) def __ne__(self, other): return not self.__eq__(other) Do you need more than that? Oleg.

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Giampaolo Rodolà
2010/5/20 John Arbash Meinel john.arbash.mei...@gmail.com: Giampaolo Rodolà wrote: class A: ...     def echo(self, x): ...             return x ... a = A() a.echo() Traceback (most recent call last):   File stdin, line 1, in module TypeError: echo() takes exactly 2 arguments (1 given)

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Oleg Broytman
On Wed, May 19, 2010 at 09:56:03AM +0100, Gustavo Narea wrote: I think it'd be useful enough to go in the standard library. Now that there's a sample implementation, should I still try to demonstrate why I believe it's worth adding to the stdlib and get support? I think yes. How many

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Michael Foord
On 20/05/2010 10:49, Giampaolo Rodolà wrote: 2010/5/20 John Arbash Meineljohn.arbash.mei...@gmail.com: Giampaolo Rodolà wrote: class A: ... def echo(self, x): ... return x ... a = A() a.echo() Traceback (most recent call last):

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Steven D'Aprano
On Thu, 20 May 2010 08:40:25 pm Oleg Broytman wrote: On Wed, May 19, 2010 at 09:56:03AM +0100, Gustavo Narea wrote: I think it'd be useful enough to go in the standard library. Now that there's a sample implementation, should I still try to demonstrate why I believe it's worth adding to the

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread geremy condra
On Wed, May 19, 2010 at 1:56 AM, Gustavo Narea m...@gustavonarea.net wrote: Hello, Oleg. class UnorderedList(list):    def __eq__(self, other):        if not isinstance(other, UnorderedList):            return False        return sorted(self) == sorted(other)    def __ne__(self, other):

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread R. David Murray
On Thu, 20 May 2010 11:49:02 +0200, =?ISO-8859-1?Q?Giampaolo_Rodol=E0?= g.rod...@gmail.com wrote: 2010/5/20 John Arbash Meinel john.arbash.mei...@gmail.com: a.echo() Traceback (most recent call last): =A0 File stdin, line 1, in module TypeError: echo() takes exactly 2 arguments (1 given)

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Michael Foord
On 20/05/2010 17:02, geremy condra wrote: On Wed, May 19, 2010 at 1:56 AM, Gustavo Naream...@gustavonarea.net wrote: Hello, Oleg. class UnorderedList(list): def __eq__(self, other): if not isinstance(other, UnorderedList): return False return

[Python-Dev] bug or feature? fixing argparse's default help value for version actions

2010-05-20 Thread Steven Bethard
Sorry I haven't had time to get around to the argparse issues. I should have time this weekend. I need a release manager call on one of the issues though. Two things I assume are fine to fix at this stage: * In the documentation, the '--version' example should either not use a shorthand, or

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Terry Reedy
On 5/20/2010 4:02 AM, Floris Bruynooghe wrote: TypeError: invoked as a method, echo() takes exactly 1 argument (0 given) captures the semantics, but is perhaps too verbose. How about: TypeError: bound method echo() takes exactly 1 argument (0 given) That way you can also have: unbound

Re: [Python-Dev] bug or feature? fixing argparse's default help value for version actions

2010-05-20 Thread Brett Cannon
On Thu, May 20, 2010 at 09:18, Steven Bethard steven.beth...@gmail.com wrote: Sorry I haven't had time to get around to the argparse issues. I should have time this weekend. I need a release manager call on one of the issues though. Two things I assume are fine to fix at this stage: * In the

Re: [Python-Dev] bug or feature? fixing argparse's default help value for version actions

2010-05-20 Thread Eric Smith
Brett Cannon wrote: In the end it's Benjamin's call, but my vote is to make the change. The chances someone wanted None as their help message is so bloody small and this is such a good UX change that I'm +1 on making the change. I completely agree. -- Eric.

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Martin v. Löwis
I think it'd be useful enough to go in the standard library. Now that there's a sample implementation, should I still try to demonstrate why I believe it's worth adding to the stdlib and get support? Most definitely. Just in case it isn't clear: nobody else seems to think this is useful (let

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Martin said: Most definitely. Just in case it isn't clear: nobody else seems to think this is useful (let alone useful enough to go into the standard library). In addition, it's trivial to implement, more reason not to add it. Yeah, fair enough. Thanks for your responses! :) -- Gustavo Narea

[Python-Dev] Adding a new C API function in 2.6

2010-05-20 Thread Antoine Pitrou
Hello, I would like to check that it's possible to a new C API function in the 2.6 branch, on the basis that it would help solve what seems to be reported as a security problem by several vendors (including Linux distributions) -- see http://bugs.python.org/issue5753 for a thorough discussion.

Re: [Python-Dev] Adding a new C API function in 2.6

2010-05-20 Thread Guido van Rossum
Sounds good to me, since this is (a) a security fix that will make some vendors happy, and (b) only a C-level API. I expect that some apps embedding Python will use this API unconditionally and this break with earlier Python versions; this could be intentional because of the vulnerability (else

Re: [Python-Dev] Incorrect length of collections.Counter objects / Multiplicity function

2010-05-20 Thread Gustavo Narea
Anyone? Gustavo said: Hello, everyone. I've checked the new collections.Counter class and I think I've found a bug: from collections import Counter c1 = Counter([1, 2, 1, 3, 2]) c2 = Counter([1, 1, 2, 2, 3]) c3 = Counter([1, 1, 2, 3]) c1 == c2 and c3 not in (c1, c2) True

Re: [Python-Dev] Incorrect length of collections.Counter objects / Multiplicity function

2010-05-20 Thread Facundo Batista
On Thu, May 20, 2010 at 5:59 PM, Gustavo Narea m...@gustavonarea.net wrote: Anyone? The best place to post a bug is the bug tracker [0]: you'll surely receive proper attention there. Regards, [0] http://bugs.python.org/ -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr:

Re: [Python-Dev] Incorrect length of collections.Counter objects / Multiplicity function

2010-05-20 Thread Mark Dickinson
On Tue, May 18, 2010 at 11:00 PM, Gustavo Narea m...@gustavonarea.net wrote: I've checked the new collections.Counter class and I think I've found a bug: from collections import Counter c1 = Counter([1, 2, 1, 3, 2]) c2 = Counter([1, 1, 2, 2, 3]) c3 = Counter([1, 1, 2, 3]) c1 == c2 and

Re: [Python-Dev] Incorrect length of collections.Counter objects / Multiplicity function

2010-05-20 Thread Mark Dickinson
On Thu, May 20, 2010 at 10:18 PM, Mark Dickinson dicki...@gmail.com wrote: See also this recent thread on python-list, and in particular the messages from Raymond Hettinger in that thread: http://mail.python.org/pipermail/python-list/2010-March/thread.html Sorry, bad thread link. Try:

Re: [Python-Dev] Adding a new C API function in 2.6

2010-05-20 Thread Barry Warsaw
On May 20, 2010, at 12:53 PM, Guido van Rossum wrote: Sounds good to me, since this is (a) a security fix that will make some vendors happy, and (b) only a C-level API. I expect that some apps embedding Python will use this API unconditionally and this break with earlier Python versions; this

Re: [Python-Dev] Adding a new C API function in 2.6

2010-05-20 Thread Martin v. Löwis
Should we start thinking about releasing 2.6.6 soonish? By tradition, it should come out soon after 2.7 and be the last bugfix (except for security patches). I guess what I mean is, should we have (at least) one more point release before the post-2.7 last-bug-fix-release? Because it's a

Re: [Python-Dev] bug or feature? fixing argparse's default help value for version actions

2010-05-20 Thread Benjamin Peterson
2010/5/20 Steven Bethard steven.beth...@gmail.com: Sorry I haven't had time to get around to the argparse issues. I should have time this weekend. I need a release manager call on one of the issues though. Two things I assume are fine to fix at this stage: * In the documentation, the

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Greg Ewing
Ben Finney wrote: Something like 1 argument in addition to 'self' would be reasonably clear and would cover both situations. Except that there's nothing special to the syntax or parser about the name ‘self’. That's true, but the use of the word 'self' here isn't meant to refer to the name

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Greg Ewing
Floris Bruynooghe wrote: Not having looked at the code I don't know how hard it is for the code that raises this traceback to notice if it's a bound or unbound method tough. The way things currently work, it would be quite difficult. The exception is raised when attempting to call the

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Greg Ewing
Giampaolo Rodolà wrote: unbound method echo() must be called with A instance as first argument (got nothing instead) It talks about arguments while no arguments are actually involved in the problem: just a class I forgot to initialize. It's hard to see how this could be improved. If you had

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Cameron Simpson
On 20May2010 17:46, Ben Finney ben+pyt...@benfinney.id.au wrote: | Would it help if the traceback showed the ‘repr()’ of each of the | arguments received? That way it would be much clearer when the instance | was received as the first argument. I've occasionally passed large or deep dicts etc to

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Ben Finney
Cameron Simpson c...@zip.com.au writes: On 20May2010 17:46, Ben Finney ben+pyt...@benfinney.id.au wrote: | Would it help if the traceback showed the ‘repr()’ of each of the | arguments received? That way it would be much clearer when the instance | was received as the first argument. I've

[Python-Dev] PEP 3148 ready for pronouncement

2010-05-20 Thread Brian Quinlan
The PEP is here: http://www.python.org/dev/peps/pep-3148/ I think the PEP is ready for pronouncement, and the code is pretty much ready for submission into py3k (I will have to make some minor changes in the patch like changing the copyright assignment):

Re: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

2010-05-20 Thread Steven D'Aprano
On Fri, 21 May 2010 10:53:16 am Greg Ewing wrote: Ben Finney wrote: Something like 1 argument in addition to 'self' would be reasonably clear and would cover both situations. Except that there's nothing special to the syntax or parser about the name ‘self’. That's true, but the use of

Re: [Python-Dev] Documenting [C]Python's Internals

2010-05-20 Thread Yaniv Aknin
This link has all post concatenated together in reverse order of how they should be read. The tags link returns the same page. Does your blog software allow you to make a master post and update with new links as available? Ugh, either it doesn't or I couldn't find the feature (I'm using