String to valid Python identifier

Дамјан Георгиевски gdamjan at gmail.com
Wed Aug 5 21:05:30 CEST 2009


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.


-- 
дамјан ( http://softver.org.mk/damjan/ )

Religion ends and philosophy begins, 
just as alchemy ends and chemistry begins 
and astrology ends, and astronomy begins.



More information about the Python-list mailing list