Re: Overloading __init__ & Function overloading

2005-09-30 Thread John J. Lee
Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes: > "Iyer, Prasad C" <[EMAIL PROTECTED]> writes: > > But I want to do something like this > > > > class BaseClass: > > def __init__(self): > > # Some code over here > > def __init__(self, a, b): > > # Some code over

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Fredrik Lundh
"Iyer, Prasad C" wrote: > Thanks a lot for the reply. > But I want to do something like this > > class BaseClass: > def __init__(self): > # Some code over here > def __init__(self, a, b): > # Some code over here > def __init__(self, a, b, c): > # some code here did you read the FAQ I pointed you

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Christopher Subich
Iyer, Prasad C wrote: > Thanks a lot for the reply. > But I want to do something like this > > class BaseClass: > def __init__(self): > # Some code over here > def __init__(self, a, b): > # Some code over here > def __init__(self, a, b, c): >

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Istvan Albert
in python you can provide default values for your parameters: class BaseClass: def __init__(self, a=None): if a is None: #no parameter pass else: #one parameter pass baseclass1=BaseClass() baseclass2=BaseClass(1) --

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Fredrik Lundh
Larry Bates wrote: >I may be reading this question different than Fredrik. it looks like you're using a non-standard definition of the word "overloading". here are the usual definitions (quoting from a random google page): "Overloading a method refers to having two methods which share the

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Paul Rubin
"Iyer, Prasad C" <[EMAIL PROTECTED]> writes: > But I want to do something like this > > class BaseClass: > def __init__(self): > # Some code over here > def __init__(self, a, b): > # Some code over here > def __init__(self, a, b, c): > #

RE: Overloading __init__ & Function overloading

2005-09-30 Thread Iyer, Prasad C
__init__ & Function overloading I may be reading this question different than Fredrik. This example is with old-style classes. class baseclass: def __init__(self, arg): # # Do some initialization # def method1(self, arg): # # baseclass method

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Michael Hoffman
Larry Bates wrote: > class myclass(baseclass): > def __init__(self, arg): > # > # This method gets called when I instantiate this class. > # If I want to call the baseclass.__init__ method I must > # do it myself. > # > baseclass.__init__(arg) T

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Larry Bates
I may be reading this question different than Fredrik. This example is with old-style classes. class baseclass: def __init__(self, arg): # # Do some initialization # def method1(self, arg): # # baseclass method goes here # class myclass(ba

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Steve Holden
Iyer, Prasad C wrote: > I am new to python. > I have few questions > a. Is there something like function overloading in python? Not in the same way as Java: you can't write several functions and have the compiler or run-rime system work out which one to call according to argument types. Don't fo

Re: Overloading __init__ & Function overloading

2005-09-30 Thread Fredrik Lundh
"Iyer, Prasad C" wrote: > a. Is there something like function overloading in python? not in the usual sense, no. function arguments are not typed, so there's nothing to dispatch on. there are several cute tricks you can use to add dispatching on top of "raw" python, but that's nothing you shou

Overloading __init__ & Function overloading

2005-09-30 Thread Iyer, Prasad C
I am new to python. I have few questions a. Is there something like function overloading in python? b. Can I overload __init__ method Thanks in advance regards prasad chandrasekaran --- Cancer cures smoking -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]