[pythonvis] Re: print"Hello world."

  • From: "Dang Manh Cuong" <dangmanhcuong@xxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Tue, 29 Apr 2014 19:30:27 +0700

Hello
I'm jaws user. The way I usually do when I learn python is create a batch file to call the py file. The code folow
Suppose I have a file called hello.py, I write:

echo off
hello.py
pause
Now save the batch file (*.bat) parallel the py file, and press enter to see the output given by the program you can use Jaws cursor to see the output, and press any key to exit the batch file. ----- Original Message ----- From: "Hrvoje Katić" <hrvojekatic@xxxxxxxxx>
To: <pythonvis@xxxxxxxxxxxxx>
Sent: Tuesday, April 29, 2014 7:21 PM
Subject: [pythonvis] Re: print"Hello world."


Hello,
I just want to add that if there's a traceback or error in your code, you will not be able to see it if you run .py script just by pressing Enter on it since command line window will close instantly. So what I do is I open a folder with .py script, and I make sure that all files are unselected. Next, I press shift+applications key and then I choose Open command window here option. After that, I type in hello.py and press Enter. Then I can review the error details with my review cursor. That's how it functions on Windows. I have to check out how it works on Linux when I will be logged in at my Linux system, and I don't know for the Mac. Anyway, I will be glad if I can help You all with learning Python. I already wrote some programs with it such as SkypeTalking and PrintList as well as Extended Winamp appmodule for NVDA. I started to learn Python since 2009, and it's my favorite language, although it's not fast like C++ or JAVA, but definitely easier to learn and debug code. My Python experience is definitely not the best, but it grows up from time to time.

Regards,
Hrvoje

Dana 29.4.2014. 0:23, James Scholes je napisao:
To answer your questions about Python and how it interacts with
Terminal: Python is what we call an interpreted language, which means
that instead of compiling your entire program into machine code, i.e. an
executable, the Python interpreter runs your program one instruction at
a time.  So, if you tell it to run a file called hello.py, and that file
contains these lines:

print "Hello world!"
print "Goodbye!"

The Python interpreter will run those lines, one after the other until
it reaches the end of the file.  So you will, of course, see:

Hello world!
Goodbye world!

If there are any errors while doing this, the interpreter will pick up
on them and give you some useful information, called a traceback, to
tell you what your program was trying to do when it failed and what
exactly went wrong.  So if we make a typo on the second line and try to
run a program containing:

pritn "Goodbye world!"

You will see:

Hello world!
   File "hello.py", line 2
     pritn "Goodbye world!"
                          ^
SyntaxError: invalid syntax

First, our correctly typed statement is run, so we see our "Hello
world!" message.  But then, because we typed the N and the T in the word
"print" the wrong way round, Python tells us we've made a syntax error.
  It also gives us the line number, the line of code being interpreted
for convenience, and if you can see or be bothered counting the spaces,
a visual representation of exactly where the syntax error was found on
the line of code.  We're also told that the offending code is contained
in hello.py, which is invaluable information when you are writing
programs with many different code files.

The Python interpreter, on most systems, is invoked simply by typing
"python" at the command line (or Terminal).  This is a program, just
like any other, so on Windows it must be installed.  On Mac OS X and
most flavours of Linux, a version of the interpreter is preinstalled
which will be sufficient for your learning.  When following the
exercises in Learn Python the Hard Way, most of the time you will run
Python with one argument; the name of the file you want to run.  For
example, "python hello.py".  If you invoke the interpreter with no
arguments, i.e. by simply typing "python", you will get an interactive
prompt which allows you to run lines of Python code instantaniously.
For example:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
print "Hello world!"
Hello world!
10 + 10
20
14 / 7
2
exit()
Hope that helps.


-------------- Dang Manh Cuong HCMC University of Pedagogy: The Educational Psychology Mobile: +84 902-572-300 E-mail: dangmanhcuong@xxxxxxxxx Yahoo! ID: manhcuong0312 Skype name: dangmanhcuong facebook:

Other related posts: