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
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
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
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:
> .
>
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:
> .
>
[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
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