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
"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
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):
>
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)
--
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
"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):
> #
__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
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
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
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
"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
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]
12 matches
Mail list logo