Skip to content

Change multi-byte write to use slice notation #26

Closed
@caternuson

Description

@caternuson

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

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