G+_Thomas Chidwick Posted April 12, 2014 Share Posted April 12, 2014 I need a Python expert to help me with an error that I am getting on my strings file I worked with on the first Episode of Python. Here is my link to the file. So what is going on is that when I run the code after I had inputted everything correctly (or what I think looks correct) in to Notepad++. I saved the file and then I ran it. Once it started to run the window will open and then close on me. I do not know what is going on, I don't see any difference from what Coding101 has out on Gethub. Please help me. Thank you! https://drive.google.com/file/d/0B5MTNlVi-JbNS3lyVG9ibWdzRUU/edit?usp=sharing Link to comment Share on other sites More sharing options...
G+_Thomas Chidwick Posted April 12, 2014 Author Share Posted April 12, 2014 P.S. Please use a notepad editor app on Google Drive so that the changes gets saved on to my account. If you made any, please comment and tell me what went wrong. Link to comment Share on other sites More sharing options...
G+_Joe Maruschek Posted April 12, 2014 Share Posted April 12, 2014 It appears you got some extra stuff at the beginning of your file. The first line of the file should be: #! usr/bin/env python All the stuff you have before that is just the output of the python shell itself. In fact, you don't even need that comment line with the "#!" unless you are a Linux or Mac user that likes to run scripts from the command line. Under Windows, the .py extension is all you need so that you can double-click on a script to run it. To catch errors like this in the future, I'd suggest keeping a command window open next to your Notepad++ window so that you can run your scripts by typing on the command line: python scriptname.py It is a shame that the show didn't spend at least a few minutes on how to use IDLE, the editor that comes with Python. You could have caught your errors there, too. When you start IDLE, you first see an interactive Python shell window. This is where you can try out stuff. To write a script - what Python calls a "module" - choose File->New from the menu. A new window opens up that is a code editor window. Put your Python code here in this new window. Notice that the code lines do not run instantly like over in the interactive window. When you are ready to test your script, save it with File->Save, then run it from within IDLE by choosing Run->Run Module. Your script will be "imported" into the interactive window and you will see any errors there. I hope this helps. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 12, 2014 Share Posted April 12, 2014 This file is a copy of an interactive session. It includes Python code, but also typed commands and output. You need to remove everything except the Python code. Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted April 12, 2014 Share Posted April 12, 2014 I agree that they should show how to use IDLE. The expert's time would be better spent with something like this rather than rewriting a few lines of code that Padre has just written. Also, when you're in the Windows IDLE code editor you can just press F5 to run the program you're editing in the shell. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 12, 2014 Share Posted April 12, 2014 I've never used IDLE even once. One should at least know what it is, though, whether or not you want to use it. Link to comment Share on other sites More sharing options...
G+_Thomas Chidwick Posted April 14, 2014 Author Share Posted April 14, 2014 Can someone tell me more about the IDLE? Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 14, 2014 Share Posted April 14, 2014 IDLE is just a very basic IDE from http://python.org. It's fine for getting started, but I don't know anyone who uses it for serious programming. Programmers either use a more powerful IDE or are command-line guys like me.? Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted April 14, 2014 Share Posted April 14, 2014 Tom, I can tell you that I "discovered" that it had been installed on my PC when I just happened to see it in my Start menu. Since I had downloaded what they recommended on the show I feel they should have mentioned it. Anyway, the editor has basic features to help you write code: block indent / un-indent, comment / un-comment, syntax checking (finds errors), highlighting, etc. Like Lee said, it's fairly weak compared to commercial IDE's and pro editors but it's way better than Notepad. Link to comment Share on other sites More sharing options...
Recommended Posts