Re: overloading constructor in python?

2006-04-03 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Alex Martelli wrote: >> I guess in python we use two idioms to cover most of the uses of >> mulltiple constructors: > > ... and classmethods. OK, _three_ idioms. Oh, and factory functions. > Among the idioms we use are the following... Nobody expects the Spanglis

Re: overloading constructor in python?

2006-04-03 Thread Alex Martelli
Paddy <[EMAIL PROTECTED]> wrote: > I guess in python we use two idioms to cover most of the uses of > mulltiple constructors: > 1) Duck typing were for example if you do: > > class C1(object): > def __init__(self, n): > n = float(n) > > n could be an integer, a floating point number,, or

Re: overloading constructor in python?

2006-04-03 Thread Paddy
I guess in python we use two idioms to cover most of the uses of mulltiple constructors: 1) Duck typing were for example if you do: class C1(object): def __init__(self, n): n = float(n) n could be an integer, a floating point number,, or a string representing a float. 2) Default values to

Re: overloading constructor in python?

2006-04-03 Thread Jarek Zgoda
Larry Bates napisaƂ(a): > In python it is called duck typing but you don't need separate > constructors: > > def __init__(self, c): > if isinstance(c, int): ...do stuff... > elif isinstance(c, list): ...do stuff... > elif isinstance(c, tuple): ...do stuff... > else: > . >

Re: overloading constructor in python?

2006-04-03 Thread lennart
Larry Bates wrote: [...] > In python it is called duck typing but you don't need separate > constructors: > > def __init__(self, c): > if isinstance(c, int): ...do stuff... > elif isinstance(c, list): ...do stuff... > elif isinstance(c, tuple): ...do stuff... > else: > . >

Re: overloading constructor in python?

2006-04-03 Thread Larry Bates
[EMAIL PROTECTED] wrote: > This is probably a really stupid question, but I cant seem to find a > satisfying answer by myself so here it goes. In for example java we > could create a class dummie with several constructors, say one that > takes an int, and one that takes a String as argument. In pyt

overloading constructor in python?

2006-04-03 Thread lennart
This is probably a really stupid question, but I cant seem to find a satisfying answer by myself so here it goes. In for example java we could create a class dummie with several constructors, say one that takes an int, and one that takes a String as argument. In python it doesnt seem possible to h