Discussion:
[Tutor] AttributeError: 'str' object has no attribute 'geturl'
Joseph Quigley
2005-10-08 19:13:48 UTC
Permalink
Well, I'm back to coding more on my comic downloader and viewer and I keep
getting this error:

Traceback (most recent call last):
File "F:\Gacor\getgarf.py", line 244, in ?
getImg(Data.todayStrip)
File "F:\Gacor\getgarf.py", line 127, in getImg
Data.f.geturl()
AttributeError: 'str' object has no attribute 'geturl'

My code is attached (sorry, but it's got lot's of text)
Javier Ruere
2005-10-08 19:59:24 UTC
Permalink
Post by Joseph Quigley
Well, I'm back to coding more on my comic downloader and viewer and I
File "F:\Gacor\getgarf.py", line 244, in ?
getImg(Data.todayStrip)
File "F:\Gacor\getgarf.py", line 127, in getImg
Data.f.geturl()
AttributeError: 'str' object has no attribute 'geturl'
Class Data has a class attribute, 'f', defined as an empty string. Check if Data.f is initialized before calling getImg.
Also, why initialize with an empty str? Put a None in there or don't define the attribute at all.
A tip: in line 126 there is a print Data.f. This will show nothing in this case. When printing for debugging, error reporting or user input, always place quotes around values so that it is easier to spot empty strings or non printable characters.
Finally, keep in mind that you can always use pdb to see what's up.

Javier
Joseph Quigley
2005-10-09 14:54:54 UTC
Permalink
Post by Javier Ruere
Class Data has a class attribute, 'f', defined as an empty string. Check if Data.f is initialized before calling getImg.
Also, why initialize with an empty str? Put a None in there or don't define the attribute at all.
A tip: in line 126 there is a print Data.f. This will show nothing in this case. When printing for debugging, error reporting or user input, always place quotes around values so that it is easier to spot empty strings or non printable characters.
Finally, keep in mind that you can always use pdb to see what's up.
Javier
Thanks,
I'll try to clean up what had gotten past me.
Joseph Quigley
2005-10-09 15:23:24 UTC
Permalink
Ok, new version (sorry to bug you).
This time I've edited the program so that you can only download todays
(it won't work for any other date). Now I can connect to the server but
it sticks on "Downloading image!"

Thanks for your prevoius help.
Joe
Javier Ruere
2005-10-11 06:04:53 UTC
Permalink
Post by Joseph Quigley
Ok, new version (sorry to bug you).
This time I've edited the program so that you can only download todays
(it won't work for any other date). Now I can connect to the server but
it sticks on "Downloading image!"
Thanks for your prevoius help.
Joe
You are welcome. This time I would like to help you but the code is incomplete (import error for Image) and I have never used urllib2 so I don't really know what to do.
Again, try to debug it with pdb. Place "import pdb; pdb.set_trace()" where you want the break point and see what's going on.

Javier

Loading...