Create an instance in a class in python -


i trying create new instance of class in python. tried solution here: instances in python

but didn't work. so, main class have

if __name__ == '__main__':     tim = person     movement = person.walk() 

where "person" name of class want create , instance of. has methods want use.

i keep getting error though:

undefined variable:person 

i tried declaring class instance within actual metho, not init, got same error.

any suggestions welcome. thanks

correction: please use bracket after class if want create instance of class , use instance call method inside class.

if __name__ == '__main__':     tim = person()     movement = tim.walk() 

or less recommended

if __name__ == '__main__':     movement = person().walk() 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -