Closed MagTun closed 3 years ago
try to do list(labels)
to get a list instead of an iterator!
An alternative is to navigate on it with a for, and get what you want from each label.
To get all the label names, you could do:
label_names = [label.name for label in keep.labels()]
Or without using that 'scary' one-line syntax, the manual way is:
label_names = []
for label in keep.labels():
label_names.append(label.name)
Thanks so much for this detailed answer @bew! Thanks to you I was able to set up my script to manage my GKeep routine. Thanks!
I would like to retrieve the names of all the labels in my Gkeep.
I am using
labels = keep.labels()
but then I am unable to extract the name from it.I tried
labels.keys()
,labels.values()
,labels.get()
,labels.getattribute()
but each time I get'dict_values' object has no attribute ...
. From the doc , I see thatlabels
returnList[gkeepapi.node.Label]
but if I dolabels[0]
I get'dict_values' object is not subscriptable
My Gkeep has labels and if I print
labels
I getdict_values([<gkeepapi.node.Label object at 0x0000016149827AC0>, <gkeepapi.node.Label object at 0x0000016149834F40>])
Thanks a lot for your help!
Additionally, please provide the following information: