need the right format to create a .py file( actually i did create a .py file! :P but the thing is i'm not sure if it's executable). My file has a function defined in it and that is all. am i supposed to add extra commands into it before saving the file? because when i type .py file name in the shell it gives something like this..
>>> spelling.py
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
spelling.py
NameError: name 'spelling' is not defined
i'm doing this on python2.7.1(IDLE) in windows. it's the same even with the command line..
also, i want to know how i can input the argument after executing the file.
the contents of the file:(it's for a spell check)
Expand|Select|Wrap|Line Numbers
- def spell(arg):
- b=arg
- a=arg
- s=[]
- for i in range(len(b)):
- i=arg[i]
- arg=arg.replace(i,'')
- s.append(arg)
- arg=a
- alph=list('abcdefghijklmnopqrstuvwxyz')
- for i in range(len(arg)):
- i=arg[i]
- for j in range(26):
- j=alph[j]
- arg=arg.replace(i,j)
- s.append(arg)
- arg=a
- for i in range(len(arg)):
- for j in range(26):
- arg=arg[:i]+alph[j]+arg[i:]
- s.append(arg)
- arg=a
- for j in range(26):
- arg=arg+alph[j]
- s.append(arg)
- arg=a
- y=open('text.txt')
- x=y.read()
- x=x.split()
- for i in s:
- z=x.count(i)
- if z!=0:
- print i
- y.close()