MagicTheGathering / mtg-sdk-python

Magic: The Gathering SDK - Python
MIT License
255 stars 45 forks source link

How to access the info of a compilation of cards. #20

Closed delCatta closed 5 years ago

delCatta commented 5 years ago

Hello, Im new to coding and I'm trying to experience with Magic SDK. Im doing this:

`from mtgsdk import Card

card = Card.find(386616)` and if i print card, i get <mtgsdk.card.Card object at 0x7f63e6c42320> how do i access tho that info? I know it can be basic, i just need some help and i cant find any tutorials on this... Thanks:)

chris-maclean commented 5 years ago

Each Card instance has a number of properties as listed on the README. You can access those properties with Python dot notation, like this:

>>> from mtgsdk import Card
>>> card = Card.find(386616)
>>> card
<mtgsdk.card.Card object at 0x7f63e6c42320>
>>> card.name
'Narset, Enlightened Master'
>>> card.set_name
'Khans of Tarkir'

It looks like there's no __str__ function on Card that prints out a card's identifying information in a usage like print(card), but you could certainly write one!