deprecating the types module ? (was: problems with the types module)
Michele Simionato
mis6 at pitt.edu
Thu Dec 12 09:13:03 EST 2002
Carl Banks <imbosol at vt.edu> wrote in message news:<at894m$csj$1 at solaris.cc.vt.edu>...
> But, IIRC, the language designers are trying to phase out the types
> module. A lot of built in types (those with constructors, anyways)
> have built in symbols that serve as name of the type. So, instead of
> using IntType, you should use int. Instead of StringType, you should
> use str. Instead of FileType, you should use file.
> For static methods, you can use staticmethod.
It is nice to know, but where is it documented ?
I was mislead from the standard documentation. When you look for the
builtin-in function "type", you obtain
type(object)
Return the type of an object. The return value is a type object.
The standard module types defines names for all built-in types.
For instance:
>>> import types
>>> if type(x) == types.StringType: print "It's a string"
If really the types module has to be deprecated (which I now think it
would be a good idea) the example should be changed to
>>> if type(x) is str: print "It's a string"
which is much much better. Are really there plans to deprecated the types
module and will be the documentation changed for Python 2.3 ?
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list