[Tutor] Function Problem 3.6

Frank Bloeink frankbloeink at nerdshack.com
Fri Oct 15 10:21:22 CEST 2004


Hey Mike

there's absolutely nothing wrong with running the code in the
python-shell, it works like expected, so there is no necessity to
run it as a script.
But if you want to run it as a python script in Linux you could hava a
look at the python tutor (see section 2.2.2 for executable python
script)  -> http://docs.python.org/tut/node4.html

But since your mail-header suggests that you're using Windows, I must
admit that I haven't uses Windows for a long time and therefore don't
know how to run python scripts there. But my guess would be you just
copy the programm code into a textfile named scriptname.py and execute
it with "python scriptname.py" 
Please correct me if I'm wrong!

bye Frank

On Thu, 14 Oct 2004 17:43:03 -0400
"Comcast Mail" <cgjung at comcast.net> wrote:

> Hi Frank,
> 
> Thanks for your suggestion!  Considering that this is a beginner's
> book, it would have been nice if they clued the reader into the
> necessity to run as a script - there appears to be no such clue in the
> book.  Quickly, do you know the script procedure?  If not, I'll find
> out soon enough.
> 
> Thanks Again!
> Mike
> 
> -----Original Message-----
> From: Frank Bloeink [mailto:F.Bloeink at gmx.net] 
> Sent: Thursday, October 14, 2004 4:45 AM
> To: tutor at python.org; Comcast Mail
> Subject: Re: [Tutor] Function Problem 3.6
> 
> Hello Michael
> 
> ...
> 
> The problem with executing
> 
> print "First Line"
> newLine()
> print "Second Line"
> 
> in the python-shell is that every statement in the shell is directly
> followed by the input, meaning you get a mixture of programm code and
> output:
> >>> print "First Line"
> First Line
> >>> nl()
> 
> >>> print "Second Line"
> Second Line
> >>>
> 
> If you would run this Program as a python script outside the
> interpreter, you shoul get the expected result:
> 
> ---start the script----
> First Line
> 
> Second Line
> ---end of the output---
> 
> hth Frank
> 
> 
> P.S: This is my first post to the list, although I've read on the list
> for about 2 months. Thanks to all the members on the list for the
> informative posts, I hope I can contibute myself from time to time, at
> least at the more basic stuff for I'm only a Python-beginner, too.
> 
> 
> 
> On Thu, 14 Oct 2004 00:59:18 -0400
> "Comcast Mail" <cgjung at comcast.net> wrote:
> 
> 
> > The exercise below refers to section 3.6 in "How to think like a
> > computer scientist: Learning with Python."  
> 
> > def newLine(): 
> > 
> > print 
> > 
> > This function is named newLine. The empty parentheses indicate that
> > it has no parameters. It contains only a single statement, which
> > outputs a newline character. (That's what happens when you use a
> > print command without any arguments.) ]
> > 
> > My problem is that when I attempt the exercise above, I get the
> > following:
> > 
> >  
> > 
> > >>>def  newLine():    I then hit "enter" key,  and I get
> > 
> > . 
> > 
> >  
> > 
> > I get three ellipses, no "print" output.  If I then enter
> > 
> > >>>print "First Line."
> > 
> >  
> > 
> > Instead of getting the output "newLine()" as the book states 
> > 
> >  
> > 
> > I get an "indentationerror."
> > 
> >  
> > 
> > Obviously the >>>print "Second Line."  Doesn't work either. 
> 
> > 
> > Michael
> > 
> >  
> > 
> > 
> 
> 
> -- 
> 
> "(8) It is more complicated than you think."
>   	RFC 1925: The Twelve Networking Truths 
> 
> 


-- 

"(8) It is more complicated than you think."
  	RFC 1925: The Twelve Networking Truths 


More information about the Tutor mailing list