Hi there,
I'm having this problem with using translate() - I have a line in my code like: k.translate(None,':.-') , being called from a function, which works flawlessly under v2.6.4 but throwing in TypeError when run under v2.5

Traceback (most recent call last):
  File "./wakeONlan", line 94, in <module>
TypeError: expected a character buffer object

What does this error actually mean? And how can make it portable? Some serious reason, v2.5 can't be upgraded on the server at the moment. Any help would be greatly appreciated. Cheers!!!

Edited 6 Years Ago by MacUsers: n/a

The python 2.6 documentation says that the first argument None in str.translate is new in 2.6. Previously, the first argument had to be a string of 256 characters (translation table). I suppose you should write something like

import sys
if sys.version_info < (2, 6):
    table = ''.join(chr(i) for i in xrange(256))
    table = None

This question has already been answered. Start a new discussion instead.