Skip to content

dicts attribute of DictsView conflicts with util.base.dicts() method #643

@bmaggard

Description

@bmaggard

self.dicts = dicts

In [1]: import petl as etl

In [2]: dummy = etl.dummytable()

In [3]: dummy
Out[3]: 
+-----+-----------+---------------------+
| foo | bar       | baz                 |
+=====+===========+=====================+
|  24 | 'apples'  |  0.9829038224380889 |
+-----+-----------+---------------------+
|  44 | 'oranges' | 0.14938272048364054 |
+-----+-----------+---------------------+
|  54 | 'pears'   |  0.7060235672693753 |
+-----+-----------+---------------------+
|  58 | 'pears'   | 0.12677371544592353 |
+-----+-----------+---------------------+
|  17 | 'pears'   |  0.2684826823900752 |
+-----+-----------+---------------------+
...

In [4]: dummy.dicts()
Out[4]: 
{'foo': 24, 'bar': 'apples', 'baz': 0.9829038224380889}
{'foo': 44, 'bar': 'oranges', 'baz': 0.14938272048364054}
{'foo': 54, 'bar': 'pears', 'baz': 0.7060235672693753}
{'foo': 58, 'bar': 'pears', 'baz': 0.12677371544592353}
{'foo': 17, 'bar': 'pears', 'baz': 0.2684826823900752}
...

In [5]: table = etl.fromdicts(dummy.dicts())

In [6]: table
Out[6]: 
+-----+-----------+---------------------+
| foo | bar       | baz                 |
+=====+===========+=====================+
|  24 | 'apples'  |  0.9829038224380889 |
+-----+-----------+---------------------+
|  44 | 'oranges' | 0.14938272048364054 |
+-----+-----------+---------------------+
|  54 | 'pears'   |  0.7060235672693753 |
+-----+-----------+---------------------+
|  58 | 'pears'   | 0.12677371544592353 |
+-----+-----------+---------------------+
|  17 | 'pears'   |  0.2684826823900752 |
+-----+-----------+---------------------+
...

In [7]: table.dicts()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [7], line 1
----> 1 table.dicts()

TypeError: 'DictsView' object is not callable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIt must work in all situations, but this failed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions