Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Greg Ewing
Nick Coghlan wrote: I'm fine with exposing a memoryview.buffer_address attribute in 3.4. What about objects whose buffer address can change when the buffer isn't locked? -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Nick Coghlan
On Fri, Sep 21, 2012 at 9:37 AM, David Beazley wrote: > A memory address is a number. I think an integer is fine--if you're working > at this level, you're already on your own and expected to know what you're > doing. I'd prefer to just get the raw address without yet another level of > indi

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread David Beazley
A memory address is a number. I think an integer is fine--if you're working at this level, you're already on your own and expected to know what you're doing. I'd prefer to just get the raw address without yet another level of indirection. Other parts of the library already do this. For ins

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Glyph
Le Sep 20, 2012 à 11:35 AM, David Beazley a écrit : > Well, if it's supposed to do that, it certainly doesn't work for me in 3.3. > I get a type error about it wanting a ctypes pointer object.Even if this > worked, it still doesn't address the need to get the pointer value possibly > for

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
We've already had this terminology discussion and documented the results in PEP 362. The rest of the docs may require updates to be brought in line with that. Cheers, Nick. -- Sent from my phone, thus the relative brevity :) ___ Python-Dev mailing list

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 05:45, Ethan Furman wrote: I don't expect error messages to give a complete catalog of every problem with a specific function call. If f() reports that required argument 'a' is missing, that does not imply that no other required arguments are also missing. I think it is perfectly acc

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Ethan Furman
Steven D'Aprano wrote: I would like to see error messages reserve the terms: 1) "positional" for explicitly positional-only parameters; 2) "keyword" for explicitly keyword-only parameters; +1 ___ Python-Dev mailing list Python-Dev@python.org http://m

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Ethan Furman
Steven D'Aprano wrote: On 20/09/12 22:59, Mark Dickinson wrote: On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlan wrote: +1 for using the unqualified "argument" in these error messages to mean "positional or keyword argument" (inspect.Parameter spells it out as POSITIONAL_OR_KEYWORD, but the full

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 10:18 AM, Chris Jerdonek wrote: > On Thu, Sep 20, 2012 at 8:52 AM, Guido van Rossum wrote: >> On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson >> wrote: >>> I tried to define the error messages in terms of the callee's >>> signature. I call the formals that are not var

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 01:53, Oscar Benjamin wrote: Mark Dickinson wrote: def f(x): pass ... f() Traceback (most recent call last): File "", line 1, in TypeError: f() missing 1 required positional argument: 'x' I would say that the only problem with this terminology is that it would be good to thin

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 00:49, Antoine Pitrou wrote: On Thu, 20 Sep 2012 10:12:04 -0400 Benjamin Peterson wrote: 2012/9/20 Mark Dickinson: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, posit

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 20/09/12 22:59, Mark Dickinson wrote: On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlan wrote: +1 for using the unqualified "argument" in these error messages to mean "positional or keyword argument" (inspect.Parameter spells it out as POSITIONAL_OR_KEYWORD, but the full phrase is far too verbos

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread David Beazley
Well, if it's supposed to do that, it certainly doesn't work for me in 3.3. I get a type error about it wanting a ctypes pointer object.Even if this worked, it still doesn't address the need to get the pointer value possibly for some other purpose such as handling it off to a bunch of code

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Benjamin Peterson
2012/9/20 David Beazley : > How? I must be missing something very obvious. If you have some ctypes function that requires a pointer and you pass a memoryview, ctypes should pass the pointer to the raw memory, right? -- Regards, Benjamin ___ Python-D

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Stefan Krah
David Beazley wrote: > I have recently been experimenting with the memoryview() built-in and have > come to believe that it really needs to expose the 'buf' attribute of the > underlying Py_buffer structure as an integer (see PEP 3118). Let me explain. That sounds quite harmless. People who use

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Richard Oudkerk
On 20/09/2012 5:53pm, David Beazley wrote: How? I must be missing something very obvious. I would not call it obvious, but you can do >>> m = memoryview(bytearray(5)) >>> ctypes.addressof(ctypes.c_char.from_buffer(m)) 149979304 However, this only works for writable memoryviews.

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 11:52 AM, Guido van Rossum wrote: Maybe this is also a good time to start distinguishing between arguments (what you pass, call syntax) and parameters (what the function receives, function definition syntax)? One standard usage (and mine) is that parameters are the (local) names

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 8:52 AM, Guido van Rossum wrote: > On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson > wrote: >> I tried to define the error messages in terms of the callee's >> signature. I call the formals that are not variadic, keyword variadic, >> or keyword-only, positional. For ex

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread David Beazley
How? I must be missing something very obvious. Cheers, Dave On Sep 20, 2012, at 11:48 AM, Benjamin Peterson wrote: > 2012/9/20 David Beazley : >> I have recently been experimenting with the memoryview() built-in and have >> come to believe that it really needs to expose the 'buf' attribute of

Re: [Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread Benjamin Peterson
2012/9/20 David Beazley : > I have recently been experimenting with the memoryview() built-in and have > come to believe that it really needs to expose the 'buf' attribute of the > underlying Py_buffer structure as an integer (see PEP 3118). Let me explain. > > The whole point of PEP 3118 (as I

[Python-Dev] Memoryviews should expose the underlying memory address

2012-09-20 Thread David Beazley
I have recently been experimenting with the memoryview() built-in and have come to believe that it really needs to expose the 'buf' attribute of the underlying Py_buffer structure as an integer (see PEP 3118). Let me explain. The whole point of PEP 3118 (as I understand it) is to provide a mean

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 10:12 AM, Benjamin Peterson wrote: 2012/9/20 Mark Dickinson : Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, positional. For example, in def f(a, b, c, *args, d):

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 7:56 AM, Mark Dickinson wrote: I suspect I've missed the boat on this one (certainly for 3.3.0), but here goes. The new TypeError reporting for bad function calls is a huge improvement (thanks Benjamin!), but I have one small nitpick: what *is* a positional argument? For example:

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Oscar Benjamin
On 20 September 2012 16:14, Benjamin Peterson wrote: > 2012/9/20 Mark Dickinson : > > And excepting optional ones, too, right? E.g., the c in > > > > def foo(a, b, c=1, *args, d): > > pass > > > > can be passed to by position, but isn't "positional". > > Why not? > > >>> def f(a, b,

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Guido van Rossum
On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson wrote: > 2012/9/20 Mark Dickinson : >> Thoughts? > > I tried to define the error messages in terms of the callee's > signature. I call the formals that are not variadic, keyword variadic, > or keyword-only, positional. For example, in > > def f(a,

[Python-Dev] Take a look at Issue15421

2012-09-20 Thread Cédric Krier
Hi, Could someone take a look at the Issue15421 [1]? It is a small bug in calendar module but it generates noise on web application like roundup [2]. Thanks, [1] http://bugs.python.org/issue15421 [2] http://issues.roundup-tracker.org/issue2550765 -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 4:14 PM, Benjamin Peterson wrote: > 2012/9/20 Mark Dickinson : >> And excepting optional ones, too, right? E.g., the c in >> >> def foo(a, b, c=1, *args, d): >> pass >> >> can be passed to by position, but isn't "positional". > > Why not? Ah, okay; I was assu

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Benjamin Peterson
2012/9/20 Mark Dickinson : > And excepting optional ones, too, right? E.g., the c in > > def foo(a, b, c=1, *args, d): > pass > > can be passed to by position, but isn't "positional". Why not? >>> def f(a, b, c=3): pass ... >>> f() Traceback (most recent call last): File "", line 1

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 3:12 PM, Benjamin Peterson wrote: > As you noted in your next message, keyword-only arguments need to be > distinguished from these "positional" arguments somehow. Maybe it > helps to think of "positional" to mean "the only formals you can pass > to with position" (excepti

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Antoine Pitrou
On Thu, 20 Sep 2012 10:12:04 -0400 Benjamin Peterson wrote: > 2012/9/20 Mark Dickinson : > > Thoughts? > > I tried to define the error messages in terms of the callee's > signature. I call the formals that are not variadic, keyword variadic, > or keyword-only, positional. For example, in > > def

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson wrote: > def f(a, b, c, *args, d): > pass > > a, b, and c are positional. Hence the "positional" in error messages. > > As you noted in your next message, keyword-only arguments need to be > distinguished from these "positional" arguments som

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Benjamin Peterson
2012/9/20 Mark Dickinson : > Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, positional. For example, in def f(a, b, c, *args, d): pass a, b, and c are positional. Hence the "posi

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
On Thu, Sep 20, 2012 at 10:59 PM, Mark Dickinson wrote: > Perhaps this simply isn't worth worrying about, especially since the > current error messages are all but certain to make it into the 3.3 > release. No "all but" about it at this point - the earliest they could change again is 3.3.1. Hopef

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlan wrote: > +1 for using the unqualified "argument" in these error messages to > mean "positional or keyword argument" (inspect.Parameter spells it out > as POSITIONAL_OR_KEYWORD, but the full phrase is far too verbose for > an error message). Ah yes; I

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
On Thu, Sep 20, 2012 at 9:56 PM, Mark Dickinson wrote: > I submit that the word 'positional' in the TypeError message > exacerbates this confusion, and that little would be lost by simply > dropping it from the exception message. +1 for using the unqualified "argument" in these error messages to

[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
I suspect I've missed the boat on this one (certainly for 3.3.0), but here goes. The new TypeError reporting for bad function calls is a huge improvement (thanks Benjamin!), but I have one small nitpick: what *is* a positional argument? For example: >>> def f(x): pass ... >>> f()