Skip to content

frombuffer 'hello world' example does not work in Py3 #8933

@hpaulj

Description

@hpaulj

np.frombuffer has an example making a S1 array from "hello world". That works fine in Python 2, but in Python3 raises an error - the string object doesn't have a __buffer__ attribute.

 s = b'hello world' 

works.

I don't know if it is simpler to use separate PY2 and PY3 examples, or to come up with an example that doesn't highlight this difference. frombuffer is not usually needed by beginning to intermediate users, so an overly simple string/bytestring example might be more misleading than helpful.

http://stackoverflow.com/questions/43362986/numpy-frombuffer-attributeerror-str-object-has-no-attribute-buffer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions