[Tutor] Download file from the web and store it locally.

w chun wescpy at gmail.com
Sat May 27 07:49:12 CEST 2006


> You need to step back a bit and get a better understanding of
> variables
> and functions and how to use them. You are trying to run before you
> can walk.
>    :
> You need to sit down and work through which variables you need
> and which functions of urllib you need.
>
> I suspect you only need to use urllib.urlretrieve() and your total
> code should only be 3 or 4 lines long.


matata,

i agree with alan here.  it does not even look like your program
should even get up to the point where you think that it should be
working up to.  i suspect plenty of NameError exceptions.

what you should do is to simplify first: get rid of most variables and
definitely that exception handler (try-except). write down the steps
(in pseudocode) as to what you want to do, what variables you want to
use, etc. after you get things working, you can dress up your code
with the extras.

after that, you should be able to piece together which variables you
really need and be able to construct the proper Python code from
there.  as alan has suggested, what i think you want to do, involves
using urllib.urlretrieve() and should only take a 3-5 lines of code.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list