Type signature

paul kölle paul at subsignal.org
Mon Jul 24 13:03:56 EDT 2006


Marc 'BlackJack' Rintsch wrote:
> In <mailman.8423.1153605052.27775.python-list at python.org>, Yacao Wang
> wrote:
> 
>> However, type signatures are not only a kind of information provided for
>> the compiler, but also for the programmer, or more important, for the
>> programmer. Without it, we have to "infer" the return type or required
>> agument types of a function, and this can't be done without seeing the
>> implementation of it,
> 
> That's what documentation is meant for.  If you are forced to look at the
> implementation, the documentation is bad.
I think the OP refers to reading the *code*, the documentation might not
exist (yet). Sometimes I feel python is easier to write than to read and
 missing argument type declarations (just for documentation purposes)
are  IMHO one reason. Another are missing (optional) argument type
checks at runtime. Something like WrongArgumentType exceptions instead
of rather unspecific AttributeError from deep inside the code would be
very convenient.

Yes docstrings are nice but sometimes a simple:

foo(int:param1, string:param2) is way better than:

foo(param1, param2):
  """
  @type param1: integer
  @type parame2: string
  """

cheers
 Paul




More information about the Python-list mailing list