python - Verify if a topic exists based on topic name -


i'm trying verify if topic exists based on topic name.

do know if possible?

for example want verify if topic name "test" exist.

below i'm trying doesn't work because topicslist contains topicarns , not topicnames...

topics = sns.get_all_topics()    topicslist = topics['listtopicsresponse']['listtopicsresult'['topics']  if "test" in topicslist:     print("true") 

this kind of hack should work:

topics = sns.get_all_topics()    topic_list = topics['listtopicsresponse']['listtopicsresult']['topics'] topic_names = [t['topicarn'].split(':')[5] t in topic_list]  if 'test' in topic_names:    print(true) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - How can I echo out this array? -

javascript - IE11 incompatibility with jQuery's 'readonly'? -