Python not recognizing a named attribute?

Really perplexed on this one. Using scryfalls api (Card Objects · API Documentation · Scryfall Magic: The Gathering Search) to retrieve information on a given magic the gathering card (Queen Marchesa) and looking for the cards ‘keywords’. It can find the attribute ‘colors’ without a problem. I still see from printing all the contents of the object that it does in fact have keywords, in the same format as colors. (I cut off a chunk of the output since it was huge and had to remove web links)

if I try to get the keywords value, the expected result is [‘Haste’, ‘Deathtouch’], but I get:
AttributeError: ‘Named’ object has no attribute ‘keywords’

def test_search(card_name):
getcard = scrython.cards.Named(exact=card_name)
print (card_name)
print ("keywords: ", hasattr(getcard, ‘keywords’))
print ("colors: ", hasattr(getcard, ‘colors’))
print ()
print (getcard.dict)

Output:
Queen Marchesa
keywords: False
colors: True

{‘dict’: {‘set’: ‘’, ‘exact’: ‘Queen Marchesa’}, ‘args’: ‘set=&exact=Queen+Marchesa’, ‘url’: ‘cards/named?set=&exact=Queen+Marchesa’, ‘params’: {‘format’: ‘json’, ‘face’: ‘’, ‘version’: ‘’, ‘pretty’: ‘’}, ‘encodedParams’: ‘format=json&face=&version=&pretty=’, ‘scryfallJson’: {‘object’: ‘card’, ‘id’: ‘03f4341c-088b-4f35-b82b-3d98d8a93de4’, ‘oracle_id’: ‘d7ac4be1-dcca-49b6-8ddb-d1b0e6cf2dcf’, ‘multiverse_ids’: [416835], ‘tcgplayer_id’: 121434, ‘cardmarket_id’: 291750, ‘name’: ‘Queen Marchesa’, ‘lang’: ‘en’, ‘released_at’: ‘2016-08-26’, ‘uri’: , ‘mana_cost’: ‘{1}{R}{W}{B}’, ‘cmc’: 4.0, ‘type_line’: ‘Legendary Creature — Human Assassin’, ‘oracle_text’: ‘Deathtouch, haste\nWhen Queen Marchesa enters the battlefield, you become the monarch.\nAt the beginning of your upkeep, if an opponent is the monarch, create a 1/1 black Assassin creature token with deathtouch and haste.’, ‘power’: ‘3’, ‘toughness’: ‘3’, ‘colors’: [‘B’, ‘R’, ‘W’], ‘color_identity’: [‘B’, ‘R’, ‘W’], ‘keywords’: [‘Haste’, ‘Deathtouch’], ‘all_parts’: [{‘object’: ‘related_card’, ‘id’: ‘03f4341c-088b-4f35-b82b-3d98d8a93de4’, ‘component’: ‘combo_piece’ …

1 Like