En Wed, 26 Sep 2007 03:29:09 -0300, HYRY <[EMAIL PROTECTED]> escribi�:

> I want to add a docstring translator into the Python interpreter. If
> the user input:
>>>> a = [1,2,3]
>>>> a.append(
> this translator will show the docstring of append in my native
> language. Because __doc__ is read only, I added a dict to the
> interpreter as follows:
>
> DOC[list.append.__doc__] = """ translated version of the __doc__ """
>
> When it is the time to show docstring, the program get the translated
> version from DOC.
> This works, but I think the key of DOC is too long, so I want to use
> the id of list.append.__doc__ as the key; or use the id of
> list.append:

Don't worry about that. There is no "wasted memory" apart from some  
overhead due to the string object itself (a few bytes per string, fixed  
and not depending on the string length).
Just use the __doc__ as the dictionary key. Perhaps using an external  
database, to avoid keeping all the translated texts in memory.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to