A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-March/052228.html below:

[Python-Dev] Rationale for sum()'s design?

[Python-Dev] Rationale for sum()'s design? [Python-Dev] Rationale for sum()'s design?John Williams jrw at pobox.com
Wed Mar 16 18:37:21 CET 2005
Michael Walter wrote:
> On Tue, 15 Mar 2005 07:47:20 -0800, Guido van Rossum
> <gvanrossum at gmail.com> wrote:
> 
>>But I'm not so sure now. Thinking ahead to generic types, I'd like the
>>full signature to be:
>>
>>  def sum(seq: sequence[T], initial: T = 0) -> T.
> 
> 
> Would this _syntax_ work with generic types:
> 
>   def sum(seq: sequence[T], initial: T = T()) -> T.

This doesn't make sense with existing semantics because default 
arguments are evaluated when the function is defined, but T() can't be 
evaluated until the function is called.  I'm not sure there's a way 
around that problem without turning default arguments into a trap for 
the unwary.

jw
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4