Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoolType should be added to types.py #36394

Closed
brianquinlan opened this issue Apr 8, 2002 · 5 comments
Closed

BoolType should be added to types.py #36394

brianquinlan opened this issue Apr 8, 2002 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@brianquinlan
Copy link
Contributor

BPO 540874
Nosy @gvanrossum, @tim-one, @loewis, @brianquinlan

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/gvanrossum'
closed_at = <Date 2002-04-08.13:43:26.000>
created_at = <Date 2002-04-08.06:12:54.000>
labels = ['library']
title = 'BoolType should be added to types.py'
updated_at = <Date 2002-04-08.13:43:26.000>
user = 'https://github.com/brianquinlan'

bugs.python.org fields:

activity = <Date 2002-04-08.13:43:26.000>
actor = 'gvanrossum'
assignee = 'gvanrossum'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2002-04-08.06:12:54.000>
creator = 'bquinlan'
dependencies = []
files = []
hgrepos = []
issue_num = 540874
keywords = []
message_count = 5.0
messages = ['10207', '10208', '10209', '10210', '10211']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'tim.peters', 'loewis', 'bquinlan']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue540874'
versions = ['Python 2.3']

@brianquinlan
Copy link
Contributor Author

That's it :-)

@brianquinlan brianquinlan added the stdlib Python modules in the Lib dir label Apr 8, 2002
@brianquinlan brianquinlan added the stdlib Python modules in the Lib dir label Apr 8, 2002
@tim-one
Copy link
Member

tim-one commented Apr 8, 2002

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.

@brianquinlan
Copy link
Contributor Author

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.

@loewis
Copy link
Mannequin

loewis mannequin commented Apr 8, 2002

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.

@gvanrossum
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

3 participants