bibliopixel.control.address module¶
An address identifies how to get or set a piece of data within a Python object, called the “root”, using attributes and indexing.
An address description is a string looking like:
.foo.bar[32][5][baz].bang()
which would mean
“given an object “root”, the value root.foo.bar[32][5]['baz'].bang()
”.
Addresses are divided into “segments”.
A segment contained in brackets []
is an index (for a list) or a key (for
a dictionary) - otherwise, it’s an attribute.
In the example above, the segments are foo
, bar
, [32]
, [5]
,
[baz]
and bang
; foo
and bar
are attributes.
baz
is a string index, and 32
and 5
are numeric indexes.
You can use an Address to either get or set values in the root object.
Any key that’s entirely numeric is taken to be an integer index. This is
convenient but prevents the creation of dictionaries like {1: 'x', '1': 'y'}
which you probably didn’t want to do anyway.