2009/8/8 Дамјан Георгиевски :
>
>
>>> 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 _ ?
...
>
> ps.
> by "convert" I didn't mean a full transformation... I was more hoping
> for the least
>> 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 _ ?
>
> I think this is fairly underspecified as a problem statement. A
> solution that would meet your specification would be
True, I w
> 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 _ ?
I think this is fairly underspecified as a problem statement. A solution
that would meet your specification would be
def mkident(s):
Дамјан Георгиевски 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
'trans
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 alche