From: Paulo J. S. S. <rs...@im...> - 2004-03-11 14:18:22
|
This is a more tricky question. If I understand well enough. The name "array" in a python section relates to a factory function that builds arraytype objects. It is not the name for the array type. For example, if you type: type(array) you get <type 'builtin_function_or_method'> Which shows that it is a function, not a class object. There are more subtlety associated to the fact that Numeric does not use the new class styles as numarray does. Actually if you use numarray instead of Numeric you'll get a more sensible behavior >>> import numarray >>> a =3D numarray.array([1.,2.,3.]) >>> type(a) <class 'numarray.numarraycore.NumArray'> >>> type(a) is numarray.NumArray True >>> isinstance(a, numarray.NumArray) True >>> Best regards, Paulo Obs: You may consider using a "try: except:" statement instead of always checking type. In Python is usually better to ask "forgiveness" in a "except" clause than to ask "permission" by checking types. --=20 Paulo Jos=E9 da Silva e Silva=20 Professor Assistente do Dep. de Ci=EAncia da Computa=E7=E3o (Assistant Professor of the Computer Science Dept.) Universidade de S=E3o Paulo - Brazil e-mail: rs...@im... Web: http://www.ime.usp.br/~rsilva Teoria =E9 o que n=E3o entendemos o (Theory is something we don't) suficiente para chamar de pr=E1tica. (understand well enough to call)=20 (practice) |