Re: str class inheritance prob?

2008-04-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > so I’m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: Others already gave you the technical solution (use __new__, not __init__). A couple remarks still: 1/ > > class Path(str): >

Re: str class inheritance prob?

2008-04-16 Thread s0suk3
On Apr 16, 1:43 pm, [EMAIL PROTECTED] wrote: > so I’m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: > > class Path(str): > def __init__( self, path ): > clean = str(path).replace(

Re: str class inheritance prob?

2008-04-16 Thread Jerry Hill
On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie <[EMAIL PROTECTED]> wrote: > so I'm trying to create a class that inherits from str, but I want to run > some code on the value on object init. this is what I have: You actually want to run your code when creating the new object, not when initializ

str class inheritance prob?

2008-04-16 Thread Hamish McKenzie
so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.f

str class inheritance prob?

2008-04-16 Thread jkazoo
so I’m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.find('//'