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

%b does not work, as a binary output formatter #68300

Closed
BobStein mannequin opened this issue May 2, 2015 · 3 comments
Closed

%b does not work, as a binary output formatter #68300

BobStein mannequin opened this issue May 2, 2015 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@BobStein
Copy link
Mannequin

BobStein mannequin commented May 2, 2015

BPO 24112
Nosy @stevendaprano

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 2015-05-02.10:57:22.508>
created_at = <Date 2015-05-02.10:29:18.473>
labels = ['type-bug', 'invalid']
title = '%b does not work, as a binary output formatter'
updated_at = <Date 2015-05-02.11:04:13.284>
user = 'https://bugs.python.org/BobStein'

bugs.python.org fields:

activity = <Date 2015-05-02.11:04:13.284>
actor = 'BobStein'
assignee = 'none'
closed = True
closed_date = <Date 2015-05-02.10:57:22.508>
closer = 'steven.daprano'
components = []
creation = <Date 2015-05-02.10:29:18.473>
creator = 'BobStein'
dependencies = []
files = []
hgrepos = []
issue_num = 24112
keywords = []
message_count = 3.0
messages = ['242388', '242389', '242390']
nosy_count = 2.0
nosy_names = ['steven.daprano', 'BobStein']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24112'
versions = ['Python 2.7']

@BobStein
Copy link
Mannequin Author

BobStein mannequin commented May 2, 2015

"%b"%42 produces a ValueError exception instead of outputting '101010'

Details here: http://stackoverflow.com/a/29997703/673991

@BobStein BobStein mannequin added the type-bug An unexpected behavior, bug, or error label May 2, 2015
@stevendaprano
Copy link
Member

This is not a bug, since %b is not supported in Python 2, only in Python 3:

https://docs.python.org/2/library/stdtypes.html#string-formatting-operations

No new features will be added to 2.7, so if you need %b you can use Python 3, or in Python 2.7 you can use the newer string format method instead:

py> "{:b}".format(42)
'101010'

@BobStein
Copy link
Mannequin Author

BobStein mannequin commented May 2, 2015

Ah, you're right, my mistake.

@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-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant