3 ms·
Good example. it should let you retrieve a page in one line of code Agreed, but not the property of abstractions I talk about in this post. A good library/la
by andreyf 17y ago
Good example.
it should let you retrieve a page in one line of code
Agreed, but not the property of abstractions I talk about in this post.
A good library/language would let you cast the response of urlopen to whatever it is you need - a String, an IOStream, even a DOM object, maybe even do it automatically using type hinting/inference. Parameters are just an optional dict of data to go with the request, could easily be passed an optional variable.
- ntoshev 17y agoYes, the library designer have to anticipate what you could possibly need to alter and expose it as optional parameter. Just looking at how Python's urllib/urllib2 have evolved with versions shows this is no easy task (otherwise the developers of the standard lib would have get it exactly right the first time). And it gets tougher when you actually want to modify behavior (like handling http redirects). The support for modifying behavior in popular languages is basically events, inheritance / interface implementation, and composing pre-built objects to get the desired behavior. This leaves me wanting to have a better way.