On Thu, Feb 14, 2008 at 2:36 PM, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Eric Smith wrote:
> > Are you saying I should call _PyType_Lookup first?
>
> No, I think he's saying that you don't need to call
> _PyType_Lookup at all, because anything that it could
> find will also be found by PyObject
Eric Smith wrote:
> Are you saying I should call _PyType_Lookup first?
No, I think he's saying that you don't need to call
_PyType_Lookup at all, because anything that it could
find will also be found by PyObject_GetAttr.
So just call PyObject_GetAttr and it should Just Work.
--
Greg
___
Guido van Rossum wrote:
> Try this:
>
> if (PyInstance_Check(obj)) {
> bound_method = PyObject_GetAttr(obj, str__format__);
> if (!bound_method)
> return NULL;
>
> Py_DECREF(bound_method);
> return
> }
> else {
> do it the py3k way;
> }
Yes! I had converged on something similar.
Try this:
if (PyInstance_Check(obj)) {
bound_method = PyObject_GetAttr(obj, str__format__);
if (!bound_method)
return NULL;
Py_DECREF(bound_method);
return
}
else {
do it the py3k way;
}
On Feb 13, 2008 5:31 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
> [slight mailer problem, thi
Oops, sorry for the spam. I didn't see that there were already answers
in the rest of the thread. :-(
On Feb 13, 2008 9:25 PM, Jeffrey Yasskin <[EMAIL PROTECTED]> wrote:
> On Feb 13, 2008 1:42 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
> > Guido van Rossum wrote:
> > >> Much to my surprise, this al
On Feb 13, 2008 1:42 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
> Guido van Rossum wrote:
> >> Much to my surprise, this already works:
> >>
> >> >>> format(oldstyle(), '+^50s')
> >> '+<__main__.oldstyle instance at 0x3d91f8>+'
> >> >>>
> >>
> >> So I guess it's a moot point. I'm using th
[slight mailer problem, this might show up as a dupe. sorry]
Guido van Rossum wrote:
> On Feb 13, 2008 2:57 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
>> Guido van Rossum wrote:
>>> On Feb 13, 2008 2:20 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
Nick Coghlan wrote:
> However, the source cod
On Feb 13, 2008 2:57 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
>
> Guido van Rossum wrote:
> > On Feb 13, 2008 2:20 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
> >> Nick Coghlan wrote:
> >>> Eric Smith wrote:
> I hate to be dense, but could you point me to some code that does
> something si
Guido van Rossum wrote:
> On Feb 13, 2008 2:20 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
>> Nick Coghlan wrote:
>>> Eric Smith wrote:
I hate to be dense, but could you point me to some code that does
something similar but looks up the method by name?
>>> I was going to suggest __enter__/_
On Feb 13, 2008 2:20 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
> Nick Coghlan wrote:
> > Eric Smith wrote:
> >> I hate to be dense, but could you point me to some code that does
> >> something similar but looks up the method by name?
> >
> > I was going to suggest __enter__/__exit__, but that code
Nick Coghlan wrote:
> Eric Smith wrote:
>> I hate to be dense, but could you point me to some code that does
>> something similar but looks up the method by name?
>
> I was going to suggest __enter__/__exit__, but that code relies mainly
> on existing opcodes and just does an attribute lookup ra
Eric Smith wrote:
> I hate to be dense, but could you point me to some code that does
> something similar but looks up the method by name?
I was going to suggest __enter__/__exit__, but that code relies mainly
on existing opcodes and just does an attribute lookup rather than
explicitly bypassin
Guido van Rossum wrote:
>> Much to my surprise, this already works:
>>
>> >>> format(oldstyle(), '+^50s')
>> '+<__main__.oldstyle instance at 0x3d91f8>+'
>> >>>
>>
>> So I guess it's a moot point. I'm using the same code as I use in 3.0,
>> where I call:
>>meth = _PyType_Lookup(Py_TY
On Feb 13, 2008 12:07 PM, Eric Smith <[EMAIL PROTECTED]> wrote:
>
> Guido van Rossum wrote:
> > On Feb 13, 2008 9:48 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
> >> Guido van Rossum wrote:
> >>> On Feb 13, 2008 5:28 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
> When backporting PEP 3101, do we wa
Guido van Rossum wrote:
> On Feb 13, 2008 9:48 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
>> Guido van Rossum wrote:
>>> On Feb 13, 2008 5:28 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
When backporting PEP 3101, do we want to add __format__ to classic
classes? If so, could someone give me
On Feb 13, 2008 9:48 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
> Guido van Rossum wrote:
> > On Feb 13, 2008 5:28 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
> >> When backporting PEP 3101, do we want to add __format__ to classic
> >> classes? If so, could someone give me a pointer on how to impleme
Guido van Rossum wrote:
> On Feb 13, 2008 5:28 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
>> When backporting PEP 3101, do we want to add __format__ to classic
>> classes? If so, could someone give me a pointer on how to implement
>> this? I don't see where to hook it up.
>
> You just have to get
On Feb 13, 2008 5:28 AM, Eric Smith <[EMAIL PROTECTED]> wrote:
> When backporting PEP 3101, do we want to add __format__ to classic
> classes? If so, could someone give me a pointer on how to implement
> this? I don't see where to hook it up.
You just have to get the '__format__' attribute and c
When backporting PEP 3101, do we want to add __format__ to classic
classes? If so, could someone give me a pointer on how to implement
this? I don't see where to hook it up.
Thanks.
Eric.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.
19 matches
Mail list logo