Why Does This Variable Vanish?

sill at optonline.net sill at optonline.net
Fri May 4 02:18:53 EDT 2001


In comp.lang.python, you wrote:
>Hi;
>Here's my code:
> >>>
>    import smtplib
>    file = open("outfile.txt", "r")
>    line = file.readline()
>    server = smtplib.SMTP("localhost")
>    server.sendmail("beno at thewebsons.com", "beno at thewebsons.com", line)
>    server.quit()
><<<
>The variable *line* in the 2nd to last line of code doesn't print anything. 
>Now, if I put a *print line* command after *line = file.readline()* it'll 
>print to screen. And if I define *line = "whatever"*  and put it after the 
>*line = file.readline()* statement, in the exact_same_place as the *print 
>line* statement above, then I get an email with *whatever* in the body. So, 
>what in tarnation is going on?? Why doesn't variable *line* persist until 
>the 2nd to the last line of code? This makes no sense to me at all! Your 
>help is appreciated.
>TIA,
>BenO

It works perfectly here, with the line.

>
>


-- 
Lime and limpid green
a second scene
A fight between the blue
you once knew
        - Syd




More information about the Python-list mailing list