Re: How to test for type or instance of dict_values?

2018-12-11 Thread fabian . becker87
Very late to the party, but I just encountered a very similar problem and found a solution: ``` import collections obj = {"foo": "bar"} isinstance(obj.values(), collections.abc.ValuesView) # => True ``` Hope that helps someone out there :) On Thursday, November 17, 2016 at 9:09:23 AM UTC-8,

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Terry Reedy
On 11/17/2016 9:57 AM, Thorsten Kampe wrote: The code in question is part of an attempt to get the dimensions of multi-dimensional lists, the `isinstance` is there in order to exclude strings. You can do the exclusion directly. """ def dim(seq): dimension = [] while isinstance(seq,

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Thorsten Kampe
* Peter Otten (Thu, 17 Nov 2016 13:38:26 +0100) > > Thorsten Kampe wrote: > > > How can I test for type or instance of dictviews like dict_values? > > Why do you want to? Thanks, for the `collections.abc.ValuesView` tip. The code in question is part of an attempt to get the dimensions of

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Peter Otten
Thorsten Kampe wrote: > How can I test for type or instance of dictviews like dict_values? Why do you want to? > `isinstance({}.values, dict_values)` gives > `NameError: name 'dict_values' is not defined` You can "fix" this with >>> dict_values = type({}.values()) or, depending on the use

How to test for type or instance of dict_values?

2016-11-17 Thread Thorsten Kampe
How can I test for type or instance of dictviews like dict_values? `isinstance({}.values, dict_values)` gives `NameError: name 'dict_values' is not defined` """ >>> type({}.values()) """ Thorsten -- https://mail.python.org/mailman/listinfo/python-list