Bools and explicitness [was Re: PyWart: The problem with "print"]

Chris Angelico rosuav at gmail.com
Tue Jun 4 12:27:26 EDT 2013


On Wed, Jun 5, 2013 at 2:19 AM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> On Jun 4, 11:00 am, Chris Angelico <ros... at gmail.com> wrote:
>> You know, if you want a language with strict type declarations and
>> extreme run-time efficiency, there are some around.
>
> I don't like declaring types everywhere, i hate it. I prefer duck
> typed languages, HOWEVER, in order for duck typing to work
> consistently you must have checks and balances that the programmer can
> apply when he feels necessary. My "is_valid" built in will bridge the
> gap. We won't be forced to declare types, but we should ALWAYS add
> "type checks" to our "truth tests" unless we want to create subtle
> bugs. "is_valid" IS the answer!

Option 1:

void C_function(int x)

Option 2:

def Python_function(x):
    assert isinstance(x,int)

Is there a fundamental difference? You're basically proposing Option 2
while detesting Option 1.

ChrisA



More information about the Python-list mailing list