rstrip error python2.4.3 not in 2.5.1?

D

dirkheld

Hi,

I wrote some python code that retrieves urls from a txt file. In this
code I use .rstrip() for removing the '\n' at the end of every url.
While this code works on my mac (leopard) with python 2.5.1, this same
code fails to work on an ubuntu server with python 2.4.3

I was wondering if there is a problem with .rstrip() in that python
version?

error :
Traceback (most recent call last):
File "delgraph.py", line 62, in ?
url_metadata = d.get_url(site.rstrip())
 
T

Terry Reedy

| Hi,
|
| I wrote some python code that retrieves urls from a txt file. In this
| code I use .rstrip() for removing the '\n' at the end of every url.
| While this code works on my mac (leopard) with python 2.5.1, this same
| code fails to work on an ubuntu server with python 2.4.3
|
| I was wondering if there is a problem with .rstrip() in that python
| version?
|
| error :
| Traceback (most recent call last):
| File "delgraph.py", line 62, in ?
| url_metadata = d.get_url(site.rstrip())
| --

What is the actual error message [SyntaxError, NameError? etc] that you
clipped?
 
D

dirkheld

What is the actual error message [SyntaxError, NameError? etc] that you
clipped?

Here it is : I tought that I didn't matter because the deliciousapi
worked fine on my mac.

Traceback (most recent call last):
File "delgraph.py", line 62, in ?
url_metadata = d.get_url(site.rstrip())
File "deliciousapi.py", line 269, in get_url
document.bookmarks =
self._extract_bookmarks_from_url_history(data)
File "deliciousapi.py", line 297, in
_extract_bookmarks_from_url_history
timestamp = datetime.datetime.strptime(month_string, '%b ‘
%y')
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'
 
P

Philipp Pagel

dirkheld said:
Here it is : I tought that I didn't matter because the deliciousapi
worked fine on my mac.
Traceback (most recent call last):
File "delgraph.py", line 62, in ?
url_metadata = d.get_url(site.rstrip())
File "deliciousapi.py", line 269, in get_url
document.bookmarks =
self._extract_bookmarks_from_url_history(data)
File "deliciousapi.py", line 297, in
_extract_bookmarks_from_url_history
timestamp = datetime.datetime.strptime(month_string, '%b ‘
%y')
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'

The answer is right there: datetime.datetime has method strptime in
python 2.5 but which was not available in 2.4. A quick look into the
library reference confirms this:

----------------------------------------------------------------------
strptime( date_string, format)
Return a datetime corresponding to date_string, parsed according to format.
This is equivalent to datetime(*(time.strptime(date_string, format)[0:6])).
ValueError is raised if the date_string and format can't be parsed by
time.strptime() or if it returns a value which isn't a time tuple.

New in version 2.5.
 
T

Tim Roberts

dirkheld said:
What is the actual error message [SyntaxError, NameError? etc] that you
clipped?

Here it is : I tought that I didn't matter because the deliciousapi
worked fine on my mac.

Traceback (most recent call last):
File "delgraph.py", line 62, in ?
url_metadata = d.get_url(site.rstrip())
File "deliciousapi.py", line 269, in get_url
document.bookmarks = self._extract_bookmarks_from_url_history(data)
File "deliciousapi.py", line 297, in
_extract_bookmarks_from_url_history
timestamp = datetime.datetime.strptime(month_string, '%b ‘
%y')
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'

I suppose it is cruel of me, but I find it hilarious that you looked at
this traceback and came to the conclusion that the problem was in "rstrip".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top