On Wed, 05 Jul 2006 11:41:47 +0200, Bruno Desthuilliers wrote:
> Steven D'Aprano wrote:
>> On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote:
>>
>>
>>>Steven D'Aprano wrote:
>>>
I'm having problems with sub-classes of built-in types.
Here is a contrived example of my sub
On Tue, 04 Jul 2006 16:41:38 -0700, Alex Martelli wrote:
> As others already suggested, automating such decoration is pretty easy;
> you can do it with either a custom metaclass or a simple post-processing
> of your class in a loop. Untested details below, but the general idea
> would be somethin
Steven D'Aprano wrote:
> On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote:
>
>
>>Steven D'Aprano wrote:
>>
>>>I'm having problems with sub-classes of built-in types.
>>>
>>>Here is a contrived example of my subclass. It isn't supposed
>>>to be practical, useful code, but it illustrat
On Tue, 04 Jul 2006 18:25:14 +, Dennis Lee Bieber wrote:
> I suspect what you really want (I'm not going to open an interpreter
> to test) is:
>
> def __init__(self, value, extra=None):
> int.__init__(self, value)
Yes, that's exactly what I meant -- it was a copy-an
On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote:
> Steven D'Aprano wrote:
>> I'm having problems with sub-classes of built-in types.
>>
>> Here is a contrived example of my subclass. It isn't supposed
>> to be practical, useful code, but it illustrates my problem.
>>
>> class MyStr
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
...
> The obvious problem is, I have to create a custom method for every string
> method -- and if strings gain any new methods in some future version of
> Python, my subclass won't exhibit the correct behaviour.
As others already suggested, automating
Steven D'Aprano wrote:
> I'm having problems with sub-classes of built-in types.
>
> Here is a contrived example of my subclass. It isn't supposed
> to be practical, useful code, but it illustrates my problem.
>
> class MyStr(str):
> """Just like ordinary strings, except it exhibits special b
I'm having problems with sub-classes of built-in types.
Here is a contrived example of my subclass. It isn't supposed
to be practical, useful code, but it illustrates my problem.
class MyStr(str):
"""Just like ordinary strings, except it exhibits special behaviour
for one particular value