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

Make Python create a tuple with one element in a clean way #47066

Closed
chester mannequin opened this issue May 11, 2008 · 5 comments
Closed

Make Python create a tuple with one element in a clean way #47066

chester mannequin opened this issue May 11, 2008 · 5 comments
Labels
type-feature A feature request or enhancement

Comments

@chester
Copy link
Mannequin

chester mannequin commented May 11, 2008

BPO 2817
Nosy @loewis, @birkenfeld, @benjaminp

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 = None
closed_at = <Date 2008-05-11.14:18:41.237>
created_at = <Date 2008-05-11.13:16:15.957>
labels = ['type-feature']
title = 'Make Python create a tuple with one element in a clean way'
updated_at = <Date 2008-05-11.18:51:24.264>
user = 'https://bugs.python.org/chester'

bugs.python.org fields:

activity = <Date 2008-05-11.18:51:24.264>
actor = 'chester'
assignee = 'none'
closed = True
closed_date = <Date 2008-05-11.14:18:41.237>
closer = 'georg.brandl'
components = []
creation = <Date 2008-05-11.13:16:15.957>
creator = 'chester'
dependencies = []
files = []
hgrepos = []
issue_num = 2817
keywords = []
message_count = 5.0
messages = ['66626', '66627', '66634', '66645', '66650']
nosy_count = 4.0
nosy_names = ['loewis', 'georg.brandl', 'benjamin.peterson', 'chester']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue2817'
versions = ['Python 2.6', 'Python 2.5', 'Python 2.4', 'Python 2.3', 'Python 2.2.3', 'Python 2.2.2', 'Python 2.2.1', 'Python 2.2', 'Python 2.1.2', 'Python 2.1.1', '3rd party', 'Python 3.0']

@chester
Copy link
Mannequin Author

chester mannequin commented May 11, 2008

To create a tuple with one element, you need to do this:

>>> my_tuple = (1,)    # Note the trailing comma after the value 1
>>> type(my_tuple)
<type 'tuple'>

But if you do this

>>> my_tuple = (1)
>>> type(my_tuple)
<type 'int'>

you don't get a tuple. I thought that just putting a value inside ( )
would make a tuple. Apparently that is not the case. I hate ugly code
so it would be clean if Python would convert anything put into ( ) to
be a tuple, even if just one value was put in (without having to use
that ugly looking comma with no value after it).

@chester chester mannequin added the type-feature A feature request or enhancement label May 11, 2008
@benjaminp
Copy link
Contributor

But we need parentheses for grouping!

@birkenfeld
Copy link
Member

That's an absolute no-starter. Not the parentheses make the tuple, the
commas do. The empty tuple is the exception, not the rule.

@loewis
Copy link
Mannequin

loewis mannequin commented May 11, 2008

Just in case the previous comments aren't clear: Would you rather see

py> (3+4)*5
35

or

py> (3+4)*5
(7, 7, 7, 7, 7)

@chester
Copy link
Mannequin Author

chester mannequin commented May 11, 2008

Martin I see the point now. I appologize for not having the clear head
of seeing the possible damage that my feature request would make. I take
my request back.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants