Re: Is this a good idea or a waste of time?

2006-08-29 Thread Gabriel Genellina
At Tuesday 29/8/2006 02:45, Antoon Pardon wrote: That may be true. But one may wonder if this is a failing of the programmer or a failing of the language that doesn't support such things. In any case, I don't see how this supports the original claim that strict type checking input params is

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Antoon Pardon
On 2006-08-29, Simon Forman [EMAIL PROTECTED] wrote: Antoon Pardon wrote: On 2006-08-28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Antoon Pardon
On 2006-08-29, Gabriel Genellina [EMAIL PROTECTED] wrote: At Tuesday 29/8/2006 02:45, Antoon Pardon wrote: That may be true. But one may wonder if this is a failing of the programmer or a failing of the language that doesn't support such things. In any case, I don't see how this supports

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Simon Forman
Antoon Pardon wrote: On 2006-08-28, Scott David Daniels [EMAIL PROTECTED] wrote: Antoon Pardon wrote: On 2006-08-25, Simon Forman [EMAIL PROTECTED] wrote: ... Generally asserts should be used to enforce invariants of your code (as opposed to typechecking), or to check certain things

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Jonathan Gardner
Simon Forman wrote: If you have a reason to restrict your code to using only ints (perhaps you're packing them into an array of some sort, or passing them to a C extension module) then yes, of course it's appropriate. I politely disagree. Rather than an interface that demands an actual int,

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Antoon Pardon
On 2006-08-29, Jonathan Gardner [EMAIL PROTECTED] wrote: Simon Forman wrote: If you have a reason to restrict your code to using only ints (perhaps you're packing them into an array of some sort, or passing them to a C extension module) then yes, of course it's appropriate. I politely

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Steve Holden
Antoon Pardon wrote: On 2006-08-29, Gabriel Genellina [EMAIL PROTECTED] wrote: At Tuesday 29/8/2006 02:45, Antoon Pardon wrote: That may be true. But one may wonder if this is a failing of the programmer or a failing of the language that doesn't support such things. In any case, I don't see

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Antoon Pardon
On 2006-08-29, Steve Holden [EMAIL PROTECTED] wrote: Antoon Pardon wrote: On 2006-08-29, Gabriel Genellina [EMAIL PROTECTED] wrote: At Tuesday 29/8/2006 02:45, Antoon Pardon wrote: That may be true. But one may wonder if this is a failing of the programmer or a failing of the language that

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Antoon Pardon
On 2006-08-25, Simon Forman [EMAIL PROTECTED] wrote: asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type (in addition to seeing if they meet other kinds of precondition

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Scott David Daniels
Antoon Pardon wrote: On 2006-08-25, Simon Forman [EMAIL PROTECTED] wrote: ... Generally asserts should be used to enforce invariants of your code (as opposed to typechecking), or to check certain things while debugging. I don't understand this argument. Can't type checking be seen as

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Antoon Pardon
On 2006-08-28, Scott David Daniels [EMAIL PROTECTED] wrote: Antoon Pardon wrote: On 2006-08-25, Simon Forman [EMAIL PROTECTED] wrote: ... Generally asserts should be used to enforce invariants of your code (as opposed to typechecking), or to check certain things while debugging. I don't

Re: Is this a good idea or a waste of time?

2006-08-28 Thread [EMAIL PROTECTED]
Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. I've _never_ seen a case where enforcing types in the manner of the OP is appropriate. It fails with

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Terry Hancock
asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type [...] This is something I miss from working with more stricter languages like C++, where the compiler will tell you if a

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Antoon Pardon
On 2006-08-28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. I've _never_ seen a case where enforcing

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Gabriel Genellina
At Tuesday 29/8/2006 01:28, Antoon Pardon wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. I've _never_ seen a case where enforcing types in

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Simon Forman
Antoon Pardon wrote: On 2006-08-28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. I've _never_

Re: Is this a good idea or a waste of time?

2006-08-28 Thread Antoon Pardon
On 2006-08-29, Gabriel Genellina [EMAIL PROTECTED] wrote: At Tuesday 29/8/2006 01:28, Antoon Pardon wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully

Re: Is this a good idea or a waste of time?

2006-08-25 Thread Simon Forman
asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type (in addition to seeing if they meet other kinds of precondition constraints)? Like: def foo(a, b, c, d): assert

Re: Is this a good idea or a waste of time?

2006-08-25 Thread Hendrik van Rooyen
Simon Forman [EMAIL PROTECTED] wrote: 8- | BTW, speaking of strictness, more stricter is invalid English, | just stricter is the correct form. ;-) or alternatively the construct more strict is also acceptable - Hendrik --

Re: Is this a good idea or a waste of time?

2006-08-24 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], asincero wrote: def foo(a, b, c, d): assert type(a) == str assert type(b) == str assert type(c) == int assert type(d) == bool # rest of function follows This is something I miss from working with more stricter languages like

Re: Is this a good idea or a waste of time?

2006-08-24 Thread skip
Arcadio Would it be considered good form to begin every method or Arcadio function with a bunch of asserts checking to see if the Arcadio parameters are of the correct type (in addition to seeing if Arcadio they meet other kinds of precondition constraints)? If it works for you.

Re: Is this a good idea or a waste of time?

2006-08-24 Thread hiaips
asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type (in addition to seeing if they meet other kinds of precondition constraints)? Like: def foo(a, b, c, d): assert

Re: Is this a good idea or a waste of time?

2006-08-24 Thread [EMAIL PROTECTED]
asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type (in addition to seeing if they meet other kinds of precondition constraints)? Like: def foo(a, b, c, d): assert

Re: Is this a good idea or a waste of time?

2006-08-24 Thread Qiangning Hong
On 24 Aug 2006 20:53:49 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: That's bad form. If you insist on doing something like this, at least use isinstance(a, str) instead of typeof. But even that breaks duck typing; if a is a unicode string, that'll fail when the function may work fine