Hope this is an inappropriate question, since it involves pure python. Anyway:
I have a single file main.py with following code
class MyStudent: def __init__(self,n,a): self.full_name = n self.age = a def get_age(self): return self.age def CountToTenFunction(): for i in range(0,10): print i if __name__=="__main__": CountToTenFunction() x = MyStudent("Jan", 24) print x.get_age()
which works fine.
However, when I move
class MyStudent def CountToTenFunction()
to another file, which I call CountToTen.py
and in my main.py include this file by
from CountToTen import *
only my function CountToTenFunction() is found, but not my class. This gives the error
Message: name 'MyStudent' is not defined
So as a Python beginner, I did something wrong obviously, but have no idea what. Any suggestions?
Many thanks in advance…