Skip to content

Raise a meaningful error when trying to flatten non-tweets #667

@gdhpearson

Description

@gdhpearson

Using Jupyter in VSCode. Several of the twarc functions lead to the entire of the data being printed to the console which makes debugging a pain and generally clogs things up.

An example code that does this.

from twarc.client2 import Twarc2
from twarc.expansions import ensure_flattened


from twarc.expansions import ensure_flattened
twarc = Twarc2(SOME LOGIN INFO)

listOfIds = [SOMEIDS]

for id in listOfIds
  search = twarc.liking_users(id, max_results=100)
  for page in search:
      for profile in ensure_flattened(page):
          # Do something with the tweet
          allLikes.append({tid:profile['username']})

This code leads to every returned profile being printed in full to the console. Example of the output here.

https://imgur.com/a/X82V5K9

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions