Skip to content

Change multi-byte write to use slice notation #26

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

Closed
caternuson opened this issue Mar 14, 2021 · 0 comments · Fixed by #28
Closed

Change multi-byte write to use slice notation #26

caternuson opened this issue Mar 14, 2021 · 0 comments · Fixed by #28

Comments

@caternuson
Copy link
Contributor

As mentioned in #25, this library currently allows writing multiple memory locations by using the syntax fram[0] = [0,1,2,3] which behaves inconsistently from other Python usage, where this would attempt to store [0,1,2,3] in position [0] of fram. This should be changed to something more like fram[0:3] = [0,1,2,3] to use slice notation.

The built in bytearray provides a good reference example:

>>> foo = bytearray(4)
>>> foo[0] = [1,2,3,4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object cannot be interpreted as an integer
>>> foo[0:3] = [1,2,3,4]
>>> foo
bytearray(b'\x01\x02\x03\x04\x00')
>>> 
@askpatrickw askpatrickw linked a pull request Nov 5, 2021 that will close this issue
@kattni kattni closed this as completed in #28 Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant