Running Python on Windows from Shell -


so i've got script named 'some_class.py' located in same folder python.exe:

from __future__ import print_function  class some_class:     def say_it(self):     print('hello')  def main():     instance = some_class()     instance.say_it()  if __name__ == '__main__':     main() 

when try running following command while in python shell inside powershell:

some_class.py 

i get:

traceback (most recent call last): file "<stdin>", line 1, in <module> nameerror: name 'some_class' not defined 

python's version 3.4.1. doing wrong?

if want run using filename don't start python shell python34 some_class.py cmd prompt. if __name__ == '__main__': mean main() function run when script executed. if import script not run, point of using if __name__ == '__main__'


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -