Strong/weak typing

Terry Reedy tjreedy at udel.edu
Fri Aug 1 17:06:57 EDT 2008



MartinRinehart at gmail.com wrote:
> I'm writing Python as if it were strongly typed, never recycling a
> name to hold a type other than the original type.

Names are bound to objects with types.

> Is this good software engineering practice,

If you expand 'type' to 'category', then yes.

> or am I missing something Pythonic?

Most Python code is or could be generic.

def sum(iterable,start):
   for item in iter(iterable):
     start += item
   return start

Iterable can be any collection that is homogeneous with respect to the 
class of start and the operation of addition.  And throughout my code, I 
never use 'iterable' for anything other that a 
homegeneous-for-the-purpose collection.  I would never, for instance, 
bind it to a number.

tjr




More information about the Python-list mailing list