Дамјан Георгиевски wrote: > Is there any easy function in the stdlib to convert any random string in > a valid Python identifier .. possibly by replacing non-valid characters > with _ ? > > Python 2.x only, so no need to do Unicode. > Lookup the 'maketrans' function in the 'string' module and the 'translate' method of the 'str' class.