473,383 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

need help regarding creating a .py file and executing it using the shell(GUI).

hi, I've read through a couple threads related to my question but i guess i haven't been able to find the right one. so here's my question again..
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
  1. def spell(arg):
  2.     b=arg
  3.     a=arg
  4.     s=[]
  5.     for i in range(len(b)):
  6.         i=arg[i]
  7.         arg=arg.replace(i,'')
  8.         s.append(arg)
  9.         arg=a
  10.     alph=list('abcdefghijklmnopqrstuvwxyz')
  11.     for i in range(len(arg)):
  12.         i=arg[i]
  13.         for j in range(26):
  14.             j=alph[j]
  15.             arg=arg.replace(i,j)
  16.             s.append(arg)
  17.             arg=a
  18.     for i in range(len(arg)):
  19.         for j in range(26):
  20.             arg=arg[:i]+alph[j]+arg[i:]
  21.             s.append(arg)
  22.             arg=a
  23.         for j in range(26):
  24.             arg=arg+alph[j]
  25.             s.append(arg)
  26.             arg=a    
  27.     y=open('text.txt')
  28.     x=y.read()
  29.     x=x.split()
  30.     for i in s:
  31.         z=x.count(i)
  32.         if z!=0:
  33.             print i
  34.     y.close()
Mar 21 '11 #1
2 1380
try to import spelling.py,
then you can call the function from the shell! :)
Mar 21 '11 #2
thanks, but i couldn't call it that way. had to put in the lines
if__name__=="__main__":
spell(raw_input(""))

at the end.found this in someone's program :P. now it works just the way i wanted.
this thread is answered.
Mar 24 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: David Isaac | last post by:
"Alan Isaac" <aisaac0@verizon.net> wrote in message news:_A34e.2207$1r6.248@trnddc02... > I'd like to try personal financial management using Python. > I just found PyCheckbook, but it does not...
8
by: nbaiju | last post by:
Hi, I am building a asp.net application which has satellite assemblies. When building the satellite assemblies dll's from Visual Studio 2003 GUI the application works fine . i.e. the resource...
3
by: Locke Nash Cole | last post by:
I've made my first collection. Its a simple one but it works. Now I want to populate a treeview from my collection to display to the user, easy enough... But now comes my dilemma.. say I add a...
11
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
3
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display an array of objects using a GUI. My instructions are that the CD class and it's sublcass don't need to change I just need to modify class CDInventory to include the GUI. I'm not...
11
by: subramanian100in | last post by:
Suppose the following is in Test.h #ifndef TEST_H #define TEST_H #include <iostream> #include <string> using namespace std;
0
by: EricBlair | last post by:
I have this vbs script below that gets copied onto a remote computer by another script. However, this does not run the GUI app interactively, instead what it does is it runs psexec on the task...
3
by: TheSaint | last post by:
hi there, I've started to build a GUI for my Mailsweeper by the help of QT4 Designer. I came across the problem that there isn't any prebuild file browser like Kdialog. I know some other...
3
by: techquest | last post by:
Hi, I want to connect into oracle database and export the table data into a flat file using UNIX shell scripts. I cant use other GUI tools to do this, as the dataload will be in millions. hence if...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.