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
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
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
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
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
[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
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
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.
"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
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
> > 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
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
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
> "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
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
15 matches
Mail list logo