Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert 2.7 t0 3.5
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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]?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
In addition, until I got it working I would break the code out of the list comprehension, and then create a new one.
Reply
#5
Thanks I got it to work in 3.5
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020