Le samedi 04 juin 2011 à 04:56 -0700, Vinzent Steinberg a écrit :
> On 3 Jun., 21:41, Ronan Lamy <[email protected]> wrote:
> > > Yeah, ZZ, QQ, etc. are all just about syntactic sugar that makes things
> > > much shorter to type. You can do all of the stuff equivalently in much
> > > longer forms.  And by the way, the ZZ[x] syntax just exists because
> > > that's the mathematical notation (the square brackets).  The real
> > > confusing thing is that ZZ(x) is not the field of rational functions in
> > > x with integer coefficients (for that you need ZZ.frac_field(x)).
> >
> > A lot of time is wasted for the sake of a few keystrokes. To understand
> > anything using "domains", you need to unpick all the levels of
> > indirection (e.g. ZZ = ZZ_python = PythonIntegerRing which is a wrapper
> > for PythonIntegerType = int) and understand of a lot of methods and
> > syntactic shortcuts. It's much easier to understand 'isinstance(a,
> > int_type)' than 'ZZ.of_type(a)', even if the latter is shorter.
> 
> Shouldn't 'ZZ.of_type(a)' rather be 'ZZ.contains(a)' or 'a in ZZ', for
> the sake of consistency with mathematical notation?

No, it shouldn't, because ZZ isn't a set. That's indeed the problem with
using the name of an abstract mathematical set to designate a concrete
type. "Symbol('n', integer=True) in ZZ" looks like something that should
obviously be True, but actually it doesn't make sense. So 'isinstance(a,
int_type)' isn't just more readable, it also prevents dangerous
misunderstandings.

BTW, ZZ.__contains__ does exist and does something different from
ZZ.of_type.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to