0

Surprisingly this simple program doesn't work and I wonder why, and whether it is possible to make it working (without removing parameter type specification):

class Outer:
    class Inner:
        def __init__(self, parent: Outer):
            self.parent = parent

It complains that Outer is not defined. Any ideas?

vaultah
  • 44,105
  • 12
  • 114
  • 143
ardabro
  • 1,907
  • 16
  • 31
  • Note that you rarely actually need to nest classes in Python. There is probably another approach to whatever it is you're doing. – jonrsharpe Sep 15 '16 at 21:16
  • Someone posted and removed this link (so I've added it again) http://stackoverflow.com/a/36286947/2314391 – Will Sep 15 '16 at 21:17
  • @Will the auto-comment was removed because this question has been closed as a duplicate of that one, so the link is now in the banner at the top of the page. There's no need to add it again. – jonrsharpe Sep 15 '16 at 21:21
  • Ok, Thank You all – ardabro Sep 15 '16 at 21:26

0 Answers0