I would second this. Rather than checking the actual type for an  
Integer, it should do "x = Integer(x)" to accept anything that can be  
turned into an Integer.

There is a case to be made for Python's semantics of  "correct type  
== has the right methods," so I don't think we should be checking  
types everywhere, but if an invalid object is given as input, it  
should raise an exception at some level rather than returning (that  
is what is so disconcerting about this example--it doesn't raise an  
error until you try and do something, potentially much later).

Just my $0.02.

- Robert

On Mar 8, 2008, at 8:46 AM, William Stein wrote:

>
> Hi Mike,
>
>
> This looks kind of silly:
>
> sage: Partitions('mike hansen')
> Partitions of the integer mike hansen
> sage: Partitions([1..4])
> Partitions of the integer [1, 2, 3, 4]
> sage: list(Partitions([1..4]))
>
> Could you add some type checking to Partitions, e.g., an isinstance?
>
> More generally (addressed to sage-devel), do people have a general
> impression that
> we should be doing more type checking on user facing functions than we
> currently do?
> Has anybody written snippets of code for making some of this
> systematic, and they
> actually liked said code?
>
>  -- William
>
> -- 
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>
> 

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to