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

Define binary data representation in Python #60928

Closed
techtonik mannequin opened this issue Dec 19, 2012 · 13 comments
Closed

Define binary data representation in Python #60928

techtonik mannequin opened this issue Dec 19, 2012 · 13 comments
Labels
docs Documentation in the Doc dir

Comments

@techtonik
Copy link
Mannequin

techtonik mannequin commented Dec 19, 2012

BPO 16724
Nosy @rhettinger, @amauryfa, @bitdancer, @asvetlov, @cjerdonek

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 2012-12-20.05:12:22.851>
created_at = <Date 2012-12-19.09:36:38.212>
labels = ['invalid', 'docs']
title = 'Define `binary data` representation in Python'
updated_at = <Date 2012-12-20.05:12:22.838>
user = 'https://bugs.python.org/techtonik'

bugs.python.org fields:

activity = <Date 2012-12-20.05:12:22.838>
actor = 'rhettinger'
assignee = 'docs@python'
closed = True
closed_date = <Date 2012-12-20.05:12:22.851>
closer = 'rhettinger'
components = ['Documentation']
creation = <Date 2012-12-19.09:36:38.212>
creator = 'techtonik'
dependencies = []
files = []
hgrepos = []
issue_num = 16724
keywords = []
message_count = 13.0
messages = ['177727', '177728', '177749', '177752', '177756', '177758', '177759', '177763', '177764', '177765', '177767', '177796', '177798']
nosy_count = 7.0
nosy_names = ['rhettinger', 'amaury.forgeotdarc', 'techtonik', 'r.david.murray', 'asvetlov', 'chris.jerdonek', 'docs@python']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue16724'
versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Dec 19, 2012

http://docs.python.org/3/library/binascii

  • binascii.hexlify(data)
    + binascii.hexlify(bytes)

tag:easy

@techtonik techtonik mannequin assigned docspython Dec 19, 2012
@techtonik techtonik mannequin added the docs Documentation in the Doc dir label Dec 19, 2012
@amauryfa
Copy link
Member

Why? The binascii module consistently uses "data" to refer to binary data. For example:
"Return the hexadecimal representation of the binary data. Every byte of data is converted ..."

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Dec 19, 2012

In Python 2 there was no 'binary data' type - everything was a string. Now we have string, str, bytearray, array, list of ints. If hexlify is not accepting anything except bytes, it is better be explicit.

When porting code from Python 2 the argument was passed as a string with escapes inside, so it took some time to figure out why it didn't work in Py3k (actually it took a lot of time, because the research path turned wrong way at this point).

@amauryfa
Copy link
Member

If hexlify is not accepting anything except bytes, it is better be explicit.

But it is very explicit in the link you provided: both a note at the top, and the words "binary data" in the description of every function.

@asvetlov
Copy link
Contributor

I agree: the docs is good and don't needed to be modified.

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Dec 19, 2012

Fact no.1: When people use docs as a reference, they don't read top notes.

Face no.2:
This is not explicit:
binascii.hexlify(data)
This is:
binascii.hexlify(bytes)

I understand that you like the wording in description, but can't understand why don't want to fix this stuff above.

@amauryfa
Copy link
Member

When people use docs as a reference, they don't read top notes.
Maybe, but they can read some words beyond the function name, can't they?

@serhiy-storchaka
Copy link
Member

If hexlify is not accepting anything except bytes, it is better be explicit.

However hexlify is accepting something except bytes. It is accepting any object which supports buffer protocol.

@bitdancer
Copy link
Member

We do not use data type names as formal parameter names. You will realize this is sensible if you consider that in most cases in Python the formal parameter name is something gets used in more than just the documentation, and that using a type name would shadow the type name, which is something we prefer to avoid.

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Dec 19, 2012

The fact that array.array, bytearray and memoryview are also accepted is a surprise for me. It will help if Python docs contained a definition of what can be considered 'binary data' and link this term from hexlify description to this definition.

@techtonik techtonik mannequin reopened this Dec 19, 2012
@techtonik techtonik mannequin removed the invalid label Dec 19, 2012
@techtonik techtonik mannequin changed the title Rename data argument names to bytes Define binary data representation in Python Dec 19, 2012
@amauryfa
Copy link
Member

Isn't such a definition already present in the top-level paragraphs?

@cjerdonek
Copy link
Member

It will help if Python docs contained a definition of what can be considered 'binary data' and link this term from hexlify description to this definition.

I believe this is part of the goal of bpo-16518, where "bytes-like object" is being proposed as one of the terms for addition to the glossary.

@rhettinger
Copy link
Contributor

I concur with Amaury and Andrew. The docs are fine as-is.

@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
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

6 participants