Overloaded Constructor

paralizer at my-deja.com paralizer at my-deja.com
Wed Oct 18 05:09:03 EDT 2000


Thank you...


In article <39ed5438.86008483 at news.eunet.no>,
  thomas at cintra.no (Thomas Weholt) 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
> 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?
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list