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, Terry Reedy wrote:
> 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, (list, tuple)):
> 
>      while not isinstance(seq, str) # or (str, bytes, ...)
> 
> >         dimension.append(len(seq))
> >         try:
> >             seq = seq[0]
> >         except IndexError:  # sequence is empty
> >             break
> >     return dimension
> > """
> >
> > Thorsten
> >
> 
> 
> -- 
> Terry Jan Reedy
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to