Why does this fail?

Isaac To kkto at csis.hku.hk
Sun Jan 4 21:14:10 EST 2004


>>>>> "Dave" == Dave Murray <dlmurray at micro-net.com> writes:

    Dave> New to Python question, why does this fail?  Thanks, Dave

    Dave> f = urllib.open(URL)

urllib does not have an open function.  Instead, it has a constructor called
URLopener, which creates an object with such a method.  So instead, you have
to say

  opener = urllib.URLopener()
  f = opener(URL)

Regards,
Isaac.



More information about the Python-list mailing list