Re: Python's idiom for function overloads

2005-02-02 Thread Stephen Thorne
On Wed, 02 Feb 2005 14:45:35 -0800 (PST), Simo Melenius <[EMAIL PROTECTED]> wrote: > Philippe Fremy <[EMAIL PROTECTED]> writes: > > > You can not reproduce the C++ overload idiom but you can get something > > close with manual type testing. > > > > > To in a > > > function do an if statement wit

Re: Python's idiom for function overloads

2005-02-02 Thread Simo Melenius
Philippe Fremy <[EMAIL PROTECTED]> writes: > You can not reproduce the C++ overload idiom but you can get something > close with manual type testing. > > > To in a > > function do an if statement with the type() function? > > I am not aware of any other method. > > def a( arg1 ): > if t

Re: Python's idiom for function overloads

2005-02-01 Thread Jorgen Grahn
On Tue, 1 Feb 2005 04:17:10 +, Frans Englich <[EMAIL PROTECTED]> wrote: ... > But in Python, when one wants to be able to pass different data types into a > single "entry point" for functionality, how is that best done? To in a > function do an if statement with the type() function? Have a

Re: Python's idiom for function overloads

2005-02-01 Thread Frans Englich
On Tuesday 01 February 2005 05:02, Steven Bethard wrote: > Frans Englich wrote: > > But in Python, when one wants to be able to pass different data types > > into a single "entry point" for functionality, how is that best done? To > > in a function do an if statement with the type() function? > > I

Re: Python's idiom for function overloads

2005-02-01 Thread F. Petitjean
Le Tue, 01 Feb 2005 12:10:47 +0100, Philippe Fremy a écrit : > >> Frequently, in Python, code which checks for types, rather than >> checking for features, ends up being excessively restrictive and >> insufficiently general. > snip > > Enforcing types also brings the benefit that the program is

RE: Python's idiom for function overloads

2005-02-01 Thread Tim Golden
[Jacek Generowicz] | | To each his own, and vice versa. Vice versa? :) TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
Philippe Fremy <[EMAIL PROTECTED]> writes: > Enforcing types also brings the benefit that the program is more > deterministic. In my experience, there is a lot more benefits to have > an object whose type is clearly identified than to have function that > accepts generic objects. > > > I would g

Re: Python's idiom for function overloads

2005-02-01 Thread Philippe Fremy
Frequently, in Python, code which checks for types, rather than checking for features, ends up being excessively restrictive and insufficiently general. That's true, but checking for the exact features that are going to be needed by your code is usually quite complicated and painful to maintain.

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
"F. GEIGER" <[EMAIL PROTECTED]> writes: > As Philippe already said, use objects that support the protocol or decide > what to do with it after having checked its type. I do that, if I have to, > like so: > > 1 def doIt(arg): > 2if type(arg) == type([]): > 3map(doIt, arg) > 4 else

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
Philippe Fremy <[EMAIL PROTECTED]> writes: > Hi Frans, > > > Since Python doesn't have static typing, how is the same result as > > traditional function overloads results in acheived? > > > With dynamic typing obviously. :-) > > You can not reproduce the C++ overload idiom Of course you

Re: Python's idiom for function overloads

2005-02-01 Thread F. GEIGER
> > Since Python doesn't have static typing, how is the same result as traditional > > function overloads results in acheived? The more you program in Python, the less you are missing it. As Philippe already said, use objects that support the protocol or decide what to do with it after having che

Re: Python's idiom for function overloads

2005-01-31 Thread Steven Bethard
Frans Englich wrote: But in Python, when one wants to be able to pass different data types into a single "entry point" for functionality, how is that best done? To in a function do an if statement with the type() function? It often depends a lot on the specific use case... Do you have a partic

Re: Python's idiom for function overloads

2005-01-31 Thread Philippe Fremy
Hi Frans, Since Python doesn't have static typing, how is the same result as traditional function overloads results in acheived? With dynamic typing obviously. :-) You can not reproduce the C++ overload idiom but you can get something close with manual type testing. > To in a > function

Re: Python's idiom for function overloads

2005-01-31 Thread John Hunter
> "Frans" == Frans Englich <[EMAIL PROTECTED]> writes: Frans> Hello, Frans> Since Python doesn't have static typing, how is the same Frans> result as traditional function overloads results in Frans> acheived? With function overloads the "selection of code Frans> path depen

Python's idiom for function overloads

2005-01-31 Thread Frans Englich
Hello, Since Python doesn't have static typing, how is the same result as traditional function overloads results in acheived? With function overloads the "selection of code path depending on data type" is transparent and automatic since the typing system figure out what goes to what. But in P