# Buggy code
def update(object, config):
    global _type

    try:
        _type = (object.type == "tweet") * "tweet" + (object.type == "user") * "user"
    except AttributeError:
        _type = config.Following * "following" + config.Followers * "followers"

    if _type == "tweet":
        dt = f"{object.datestamp} {object.timestamp}"
        _data = {
            "id": object.id,
            "date": dt,
            "timezone": object.timezone,
            "location": object.location,
            "tweet": object.tweet,
            "hashtags": object.hashtags,
            "user_id": object.user_id,
            "username": object.username,
            "link": object.link,
            "retweet": object.retweet,
            "user_rt": object.user_rt,
            "essid": config.Essid,
            "mentions": object.mentions,
        }
        _object_blocks[_type].append(_data)
    elif _type == "user":
        _data = {
            "id": object.id,
            "name": object.name,
            "username": object.username,
            "bio": object.bio,
            "location": object.location,
            "url": object.url,
            "join_datetime": object.join_date + " " + object.join_time,
            "join_date": object.join_date,
            "join_time": object.join_time,
            "tweets": object.tweets,
            "following": object.following,
            "followers": object.followers,
            "likes": object.likes,
            "media": object.media_count,
            "private": object.is_private,
            "verified": object.is_verified,
            "avatar": object.avatar,
            "session": str(config.Essid),
        }
        _object_blocks[_type].append(_data)
    elif _type == "followers" or _type == "following":
        _data = {
            config.Following * "following" + config.Followers * "followers": {
                config.Username: object[_type]
            }
        }
        _object_blocks[_type] = _data
    else:
        print("Wrong type of object passed!")


# Traceback (AttributeError)
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import twint
c = twint.Config()
query= 'bar'
c.Search = query
c.Pandas = True
twint.run.Search(c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../lib/python3.6/site-packages/twint/run.py", line 201, in Search
run(config)
File ".../lib/python3.6/site-packages/twint/run.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File ".../lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File ".../lib/python3.6/site-packages/twint/run.py", line 140, in main
await self.tweets()
File ".../lib/python3.6/site-packages/twint/run.py", line 103, in tweets
await output.Tweets(tweet, "", self.config, self.conn)
File ".../lib/python3.6/site-packages/twint/output.py", line 161, in Tweets
await checkData(tweets, location, config, conn)
File ".../lib/python3.6/site-packages/twint/output.py", line 142, in checkData
panda.update(tweet, config)
File ".../lib/python3.6/site-packages/twint/storage/panda.py", line 61, in update
"user_rt": object.user_rt,
AttributeError: 'tweet' object has no attribute 'user_rt'


# Fixed code
def update(object, config):
    global _type

    try:
        _type = (object.type == "tweet") * "tweet" + (object.type == "user") * "user"
    except AttributeError:
        _type = config.Following * "following" + config.Followers * "followers"

    if _type == "tweet":
        Tweet = object
        day = weekdays[strftime("%A", localtime(Tweet.datetime))]
        dt = f"{object.datestamp} {object.timestamp}"
        _data = {
            "id": str(Tweet.id),
            "conversation_id": Tweet.conversation_id,
            "created_at": Tweet.datetime,
            "date": dt,
            "timezone": Tweet.timezone,
            "place": Tweet.place,
            "location": Tweet.location,
            "tweet": Tweet.tweet,
            "hashtags": Tweet.hashtags,
            "user_id": Tweet.user_id,
            "user_id_str": Tweet.user_id_str,
            "username": Tweet.username,
            "name": Tweet.name,
            "profile_image_url": Tweet.profile_image_url,
            "day": day,
            "hour": hour(Tweet.datetime),
            "link": Tweet.link,
            "gif_url": Tweet.gif_url,
            "gif_thumb": Tweet.gif_thumb,
            "video_url": Tweet.video_url,
            "video_thumb": Tweet.video_thumb,
            "is_reply_to": Tweet.is_reply_to,
            "has_parent_tweet": Tweet.has_parent_tweet,
            "retweet": Tweet.retweet,
            "nlikes": int(Tweet.likes_count),
            "nreplies": int(Tweet.replies_count),
            "nretweets": int(Tweet.retweets_count),
            "is_quote_status": Tweet.is_quote_status,
            "quote_id": Tweet.quote_id,
            "quote_id_str": Tweet.quote_id_str,
            "quote_url": Tweet.quote_url,
            "search": str(config.Search),
            "near": config.Near,
        }
        _object_blocks[_type].append(_data)
    elif _type == "user":
        user = object
        _data = {
            "id": user.id,
            "name": user.name,
            "username": user.username,
            "bio": user.bio,
            "location": user.location,
            "url": user.url,
            "join_datetime": user.join_date + " " + user.join_time,
            "join_date": user.join_date,
            "join_time": user.join_time,
            "tweets": user.tweets,
            "following": user.following,
            "followers": user.followers,
            "likes": user.likes,
            "media": user.media_count,
            "private": user.is_private,
            "verified": user.is_verified,
            "avatar": user.avatar,
            "background_image": user.background_image,
        }
        _object_blocks[_type].append(_data)
    elif _type == "followers" or _type == "following":
        _data = {
            config.Following * "following" + config.Followers * "followers": {
                config.Username: object[_type]
            }
        }
        _object_blocks[_type] = _data
    else:
        print("Wrong type of object passed!")