Open ptoews opened 4 years ago
Could have been used keys()
and values()
(and items()
?), like dict
s do.
My comment was on named_values()
only. Also consider collections.namedtuple
's _asdict()
.
Are you referring to the names of the new methods? I agree there might be better alternatives.
But it's not that simple: There are fixed fields per Sentence class, which are named in fields
, but there might also be additional values in data
without any name. So a single items()
or asdict()
would be misleading, since not all the values are named and therefore are not suitable for a dict, and otherwise not all information would be included in the extracted data container.
Just give them a name like _extra
(or something like that) and let it be the extra data as a list, or add each one as _extra1
, etc. Or fieldN
.
Thanks for your suggestion, I think this is indeed a better solution.
Unit tests are now done as well. Anything else to do?
Unit tests are now done as well. Anything else to do?
Awesome work.
Would be good for the readme to show an example.
Done, let me know if there is anything else
Started to resolve #107. Separated the value collection into two methods, one for named values (by
fields
) returning a dict and another one without names returning just a list. Also integrated them into__repr__
. Here is how they work currently:Some points to consider:
Cast known/named values to their actual types e.g. float?This would be a separate issue/PR where probably the parsing of messages would have to be considered.