Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Python, any class instance's method has <a href="http://docs.python.org/tutorial/classes.html#random-remarks" rel="nofollow"><code>self</code></a> passed in by the Python interpreter and all of the other arguments are shifted down one place automatically.</p> <p>In other words the Python interpreter rewrites:</p> <pre><code>urlaccess.retrieve(url, saveas) </code></pre> <p>into something that looks like this:</p> <pre><code>urlaccess.retrieve(urlaccess, url, saveas) </code></pre> <p>So you don't have to do it yourself. However, since </p> <blockquote> <p>explicit is better than implicit</p> </blockquote> <p>any instance methods you declare for a Python object must specify <strong>explicitly</strong> that they take the instance of the object as their first argument <em>even though Python will pass that argument without any action on the part of the programmer.</em></p> <p>The first argument does not <em>have</em> to be called <code>self</code> ... that is only a convention.</p> <hr> <p>So, to actually answer your question though (as mluebke did) -- you need to specify the <code>self</code> argument.</p> <pre><code>def http_error_404(url, fp, errcode, errmsg, headers, data): url.file_was_found = False # Python is treating `url` as `self` # Therefore the URL is being saved in `fp`, `fp` in `errcode`, etc. </code></pre> <p>To fix this problem add a first argument to pick up the instance.</p> <pre><code>def http_error_404(self, url, fp, errcode, errmsg, headers, data): self.file_was_found = False # Now everything should work </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload