[Python-bugs-list] [ python-Bugs-540874 ] BoolType should be added to types.py
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 08 Apr 2002 06:43:26 -0700
Bugs item #540874, was opened at 2002-04-08 02:12
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=540874&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Brian Quinlan (bquinlan)
Assigned to: Guido van Rossum (gvanrossum)
Summary: BoolType should be added to types.py
Initial Comment:
That's it :-)
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-08 09:43
Message:
Logged In: YES
user_id=6380
StringType should be in types for backwards compatibility.
There's lots of existing (user and 3rd party) code that uses
types.StringType. There's zero code that uses
types.BoolType, and I want to keep it that way.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-04-08 09:42
Message:
Logged In: YES
user_id=21627
You would never write
type(True) is type(bool(1))
Instead, you write
type(True) is bool
just the same way as you write
type("") is str
So in practice, there is no need to use the types module,
atleast not in a typical application, and for new code. All
the old code can continue to use the types module, likewise
code that needs to work across versions - but such code
would not expect types.BoolType to be present, either.
So I agree with Tim that this is not a bug.
----------------------------------------------------------------------
Comment By: Brian Quinlan (bquinlan)
Date: 2002-04-08 03:22
Message:
Logged In: YES
user_id=108973
I understand your point about isinstance being the one true
way of doing things now.
But I don't understand what your code is trying to
demonstrate.
As long as this works:
>>> type(True) is type(bool(1))
True
>>> type(1) is type(bool(1))
False
I don't see why StringType should be in types.py and
BoolType shouldn't be.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-08 02:23
Message:
Logged In: YES
user_id=31435
Probably not, Brian. types.py largely exists just for
backward compatibility now. If you want the bool type,
just say "bool"!
>>> bool
<type 'bool'>
>>> type(bool)
<type 'type'>
>>> isinstance(True, bool)
True
>>>
Like also int, str, long, file, dict, ... in 2.2, what used
to be builtin functions for constructing an object of a
given type are now *the* type objects themselves, acting as
constructors for objects of their types. There's no reason
to add them to types.py too.
Assigning to Guido in case he disagrees.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=540874&group_id=5470