comparing object with repr() is throwing NameError
<p>So I'm trying to compare a Deck object with the evaluated representation of a Deck object and getting</p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/Philipp/PycharmProjects/fnaround/src.py", line 3, in &lt;module&gt;
    print(Deck() == eval(repr(Deck())))
  File "&lt;string&gt;", line 1, in &lt;module&gt;
NameError: name 'Card' is not defined
</code></pre>

<p>I can not figure out what it is as I also have overridden the <code>__repr__</code> method in other classes and it works fine. I think it has something to do with it jumping from the Deck class to the Card class but I'm not sure. Can someone explain to me how the program is moving through the classes and how to fix the error. Thanks </p>

<pre><code>class Deck:

    suits = ['\u2660', '\u2661', '\u2662', '\u2663']
    ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']

    def __init__(self):

        self.deck = []

        for suit in self.suits:
            for rank in self.ranks:
                self.deck.append(Card(rank, suit))

    def __repr__(self):
        return 'Deck({})'.format(self.deck)

    def __eq__(self, other):
        return self.deck == other.deck

class Card:

    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit

    def __repr__(self):
        return "Card('{}', '{}')".format(self.rank, self.suit)

    def __eq__(self, other):
        return self.rank == other.rank and self.suit == other.suit

print(Deck() == eval(repr(Deck())))
</code></pre>

<p>I get this output;</p>

<pre><code>deck.py", line 32, in &lt;module&gt;
  print(Deck() == eval(repr(Deck())))
File "&lt;string&gt;", line 1, in &lt;module&gt;
TypeError: __init__() takes 1 positional argument but 2 were given
&lt;&lt;&lt; Process finished. (Exit code 1)
</code></pre>

<p>Your repr is trying to pass a second argument to <code>Deck__init__()</code>.  It only takes one.  This works</p>

<pre><code>def __repr__(self):
    return 'Deck()'.format(self.deck)
</code></pre>

python class eval repr