Python Forum

Full Version: convert 2.7 t0 3.5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my question here
Here is a line of code that I can't not convert to python 3

[images = [urlparse.urljoin(response.url, url) for url in images]

here the error
Traceback (most recent call last):
File "C:\Users\renny\Desktop\get_photo.py", line 16, in <module>
images = [urlparse.urljoin(response.url, url) for url in images]
File "C:\Users\renny\Desktop\get_photo.py", line 16, in <listcomp>
images = [urlparse.urljoin(response.url, url) for url in images]
AttributeError: 'function' object has no attribute 'urljoi]
I hope some one can help
thank you
renny Wall
In 2.7, urlparse is both a module and a function. It looks like you got them mixed up. Of course, in 3.5, the module is renamed urllib.parse, so all that is left is the function.
what does it do for you in 2.7? what do you expect it to do? what do you intend it to do? maybe, you did not intend that first [.  for me, it gave a syntax error.  maybe urlparse does not have urljoin in version 3.5. what is urljoi]?
In addition, until I got it working I would break the code out of the list comprehension, and then create a new one.
Thanks I got it to work in 3.5