[Tutor] Filter question ["quotation" and parameters]

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Apr 13 16:53:15 EDT 2004



On Tue, 13 Apr 2004, Kooser, Ara S wrote:

> Thank you for the reply. I first tried just a simple copy from with the
> same opening code and I had no problem. When I added the filter
> statement then it stopped working. I will go read up more on the
> folterFile. I guess I am entering something wrong. Here is the copy code
> I used.
>
> inp = open("lmps.txt","r")
> outp = open("out.txt","w")
> for line in inp.readlines():
>     outp.write(line)
> print "1 file copied"
> inp.close()
> outp.close()


Hi Kooser,

Sure, this code makes sense.  The program here opens up a file named
'lmps.txt', and writes a copy out to 'out.txt'.



Let's oversimplify things for a moment.  Say that we have the following
function:

###
def sayHello(name):
    print "Hello"
    print name
###


What happens if we redefine this as this?

###
def sayHello(name):
    print "Hello"
    print "name"
###


Does this make sense?  Please feel free to ask questions about this.
Good luck!




More information about the Tutor mailing list