From: Luke Kenneth Casson Leighton Date: Sun, 24 Mar 2019 10:57:17 +0000 (+0000) Subject: document new Record spec: allow placeholder objects X-Git-Tag: ls180-24jan2020~1506 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19485e60df45367c80411addfb34206304b598d0;p=ieee754fpu.git document new Record spec: allow placeholder objects --- diff --git a/src/add/example_buf_pipe.py b/src/add/example_buf_pipe.py index 005dbc17..8c4cae44 100644 --- a/src/add/example_buf_pipe.py +++ b/src/add/example_buf_pipe.py @@ -174,10 +174,12 @@ def eq(o, i): responsibility of further calling eq and returning a list of eq assignments - Record is a special (unusual, recursive) case, where the input - is specified as a dictionary (which may contain further dictionaries, + Record is a special (unusual, recursive) case, where the input may be + specified as a dictionary (which may contain further dictionaries, recursively), where the field names of the dictionary must match - the Record's field spec. + the Record's field spec. Alternatively, an object with the same + member names as the Record may be assigned: it does not have to + *be* a Record. """ if not isinstance(o, Sequence): o, i = [o], [i] @@ -190,10 +192,10 @@ def eq(o, i): val = ai.fields else: val = ai - if hasattr(val, field_name): + if hasattr(val, field_name): # check for attribute val = getattr(val, field_name) else: - val = val[field_name] + val = val[field_name] # dictionary-style specification rres = eq(ao.fields[field_name], val) res += rres else: