Processes with strange behavoir
Robert Brewer
fumanchu at amor.org
Sun Apr 4 14:29:57 EDT 2004
Markus Franz wrote:
> #!/usr/bin/python
>
> import urllib2, sys, socket, os, string
>
> # set timeout
> socket.setdefaulttimeout(4)
>
> # function for loading and printing a website
> def myfunction(url):
> try:
> req = urllib2.Request(url)
> req.add_header('Accept-Language', sys.argv[1])
> req.add_header('User-Agent', 'Mozilla/4.0
> (compatible; MSIE 6.0;
> Windows NT 5.1)')
> f = urllib2.urlopen(req)
> contents = f.read()
> output = "\n---PI001---" + sys.argv[2] +
> '---PI001---' + '---PI002-'
> + sys.argv[2] + '::' + f.geturl() + '::' + sys.argv[2] +
> "-PI002---\n" +
> contents
> print output
> del output
> f.close()
> del contents
> del f
> del req
> except:
> pass
Question to anyone--are the 'del' statements above doing anything that
doesn't happen automatically when the function closes? I was under the
impression that such explicit statements were unnecessary, but perhaps
I'm unaware of some quirk.
FuManChu
More information about the Python-list
mailing list