Overloaded Constructor
Radovan Garabik
garabik-news at spam.melkor.dnp.fmph.uniba.sk
Wed Oct 18 06:32:23 EDT 2000
Thomas Weholt <thomas at cintra.no> wrote:
: As far as I can see, Python doesn't support this. You'll have to just
: have to something like this:
: class myClass:
: def __init__(self,any_var1 = None,any_var2 = None):
: if any_var1 != None and any_var2 != None:
: dosomething_with_any_varx()
: else:
: dosomething()
: Or something ... the feature would be nice to have though. Used it in
: Java alot, but I think we would have seen it in Python allready if the
you can use something like this too:
class myClass:
def __init__(self, *args):
if args:
dosomething_with_any_varx()
else:
dosomething()
: model Python is built on allowed it ( but I have nothing to back this
: up !! )
: Thomas
: On Wed, 18 Oct 2000 07:21:06 GMT, paralizer at my-deja.com wrote:
:>How can I use overloaded constructor in Python?
:>Such as
:>
:>class myClass:
:> def __init__(self):
:> dosomething()
:> def __init__(self,any_var1,any_var2):
:> dosomething_with_any_varx()
:>
:>and when i use
:>
:> d = myClass # means i use the first constructor
:> e = myClass(yyy,zzz) # means i use the second one
:>
:>any suggestion?
:>
--
-----------------------------------------------------------
| Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
More information about the Python-list
mailing list