[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):
>
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(
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
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
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('//'