Skip to content

Define binary data representation in Python #60928

Closed

Description

@techtonik
mannequin
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']

Activity

  1. techtonik commented on Dec 19, 2012

    techtonikmannequin
    MannequinAuthor

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

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

    tag:easy

  2. amauryfa commented on Dec 19, 2012

    @amauryfa
    Contributor

    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 ..."

  3. techtonik commented on Dec 19, 2012

    techtonikmannequin
    MannequinAuthor

    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).

  4. amauryfa commented on Dec 19, 2012

    @amauryfa
    Contributor

    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.

  5. asvetlov commented on Dec 19, 2012

    @asvetlov
    Contributor

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

  6. techtonik commented on Dec 19, 2012

    techtonikmannequin
    MannequinAuthor

    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.

  7. amauryfa commented on Dec 19, 2012

    @amauryfa
    Contributor

    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?

  8. serhiy-storchaka commented on Dec 19, 2012

    @serhiy-storchaka
    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.

  9. bitdancer commented on Dec 19, 2012

    @bitdancer
    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.

  10. techtonik commented on Dec 19, 2012

    techtonikmannequin
    MannequinAuthor

    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.

  11. changed the title [-]Rename `data` argument names to `bytes`[/-] [+]Define `binary data` representation in Python[/+] on Dec 19, 2012
  12. amauryfa commented on Dec 19, 2012

    @amauryfa
    Contributor

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

  13. cjerdonek commented on Dec 20, 2012

    @cjerdonek
    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.

  14. rhettinger commented on Dec 20, 2012

    @rhettinger
    Contributor

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

  15. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions