proposed removal: the types module
You can just call 'type' on something to get the type needed. And practically all of the types listed are easy to get from some object lying about that is of the proper type. Plus Guido supports its removal. =) -Brett
On 2008-04-03 13:24, Brett Cannon wrote:
You can just call 'type' on something to get the type needed.
Well, yes, but that's just what the types module does, isn't it ? It's really just a more practical way of getting at the type object than having to create a temporary object just to get at the type object. For basic types you don't need it (e.g. int, float, str, etc.), but there are quite a few types in Python that don't have a builtin constructor, e.g. methods, modules, instances, etc. I also don't know how a 2to3 tool would handle such a removal. It would have to remove the "import types" or "from types import BuiltinMethodType", then add helper code to get at the type object and then use the generated code in all places that need the type object. -1 on removing it, since it would not help in any way. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 03 2008)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Apr 3, 2008, at 7:39 AM, M.-A. Lemburg wrote:
On 2008-04-03 13:24, Brett Cannon wrote:
You can just call 'type' on something to get the type needed.
Well, yes, but that's just what the types module does, isn't it ?
It's really just a more practical way of getting at the type object than having to create a temporary object just to get at the type object.
For basic types you don't need it (e.g. int, float, str, etc.), but there are quite a few types in Python that don't have a builtin constructor, e.g. methods, modules, instances, etc.
Plus, there are a few types in there that are difficult or impossible to get from Python. - -1 unless you can find another place to stash such types. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR/THkHEjvBPtnXfVAQIR8AP/T4LFcI75JudY69L9boSXtLd1l18Br2+H OnhBceeeibouFGelyqS09tP+HnTrYLo/wUsROpQ7QRG9MukECXiZ9LFyLtC41ESH jCbPT8nbeHjmkL4N5ym5DU+JWWZBZfDxzWp7khvYk5G4lqznWGuOnAvBNKnwHCyd YDhntCCIGo8= =ZjTI -----END PGP SIGNATURE-----
Le jeudi 03 avril 2008 à 13:24 +0200, Brett Cannon a écrit :
You can just call 'type' on something to get the type needed. And practically all of the types listed are easy to get from some object lying about that is of the proper type. Plus Guido supports its removal. =)
I don't see the point. It's not like using the types modules is considered dangerous, or unsafe, or very bad practice. It's not like there is a really better replacement, either. And I don't think maintenance of the types module is a huge burden ;)
Antoine Pitrou schrieb:
Le jeudi 03 avril 2008 à 13:24 +0200, Brett Cannon a écrit :
You can just call 'type' on something to get the type needed. And practically all of the types listed are easy to get from some object lying about that is of the proper type. Plus Guido supports its removal. =)
I don't see the point. It's not like using the types modules is considered dangerous, or unsafe, or very bad practice. It's not like there is a really better replacement, either. And I don't think maintenance of the types module is a huge burden ;)
It's considered bad practice since isinstance(egg, list) works. It's still in use because several types aren't directly available via import, e.g. CodeType. Christian
Le vendredi 04 avril 2008 à 11:32 +0200, Christian Heimes a écrit :
It's considered bad practice since isinstance(egg, list) works.
That's because the "list" builtin exists. The types module is useful for all those types that don't have a builtin name - and will probably never have - : modules, methods, etc. cheers Antoine.
On Thu, Apr 3, 2008 at 5:24 AM, Brett Cannon <brett@python.org> wrote:
You can just call 'type' on something to get the type needed. And practically all of the types listed are easy to get from some object lying about that is of the proper type. Plus Guido supports its removal. =)
It would be really helpful to see the patch that removes use of the types module from the standard library. I counted over 100 imports of the types module in the 2.6 standard library. Some of the fixes are obvious, like:: if type(etype) is types.ClassType which in 3.0 should obviously be:: if isinstance(etype, type) But other ones are not as obvious to me:: bdb.py: if not isinstance(cmd, types.CodeType): bdb.py: if not isinstance(expr, types.CodeType): copy.py: d[types.CodeType] = _deepcopy_atomic idlelib/rpc.py:copy_reg.pickle(types.CodeType, pickle_code, unpickle_code) inspect.py: return isinstance(object, types.CodeType) trace.py: if isinstance(c, types.CodeType): If someone could actually do the conversion, and show the new way to write these things, I'd feel much more confident on removing the module. Steve -- I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy
participants (6)
-
Antoine Pitrou
-
Barry Warsaw
-
Brett Cannon
-
Christian Heimes
-
M.-A. Lemburg
-
Steven Bethard