Re: Where can I find string.translate source?
[EMAIL PROTECTED] writes: Inside the file string.py I couldn't find the source code for translate. Where could it be? Object/stringmodule.c in the python source distribution. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I find string.translate source?
[EMAIL PROTECTED] wrote: The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says A collection of string operations (most are no longer used). Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as methods on the standard string object. They used to be implemented by a built-in module called strop, but strop is now obsolete itself. Inside the file string.py I couldn't find the source code for translate. Where could it be? in the string.py module, of course. if you read that comment again, you'll notice that it says many of these functions are implemented as methods on the standard string object and if you search for translate in string.py, you'll also find the source code for the translate function # Character translation through look-up table. def translate(s, table, deletions=): /... docstring snipped .../ if deletions: return s.translate(table, deletions) else: # Add s[:0] so that if s is Unicode and table is an 8-bit string, # table is converted to Unicode. This means that table *cannot* # be a dictionary -- for that feature, use u.translate() directly. return s.translate(table + s[:0]) which calls the translate method to do the work, just as the comment said. to find the method implementation, you have to look at the string object implementation. it's in the Objects directory in the source distribution. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Where can I find string.translate source?
Thanks Mike and Fredrik. In my Python installation there is no directory called Objects. I use Windows and I downloaded Python from http://www.python.org/download/ As I looked closer I saw that the link # Python 2.4.2 Windows installer (Windows binary -- does not include source) which clearly says that it doesn't include source. So in order to see the source I had to download # Python 2.4.2 source (for Unix or OS X compile) And in that download there is a directory called Objects and there is file called stringobjects.c where one can find the implementation of translate. -- http://mail.python.org/mailman/listinfo/python-list
Where can I find string.translate source?
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says A collection of string operations (most are no longer used). Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as methods on the standard string object. They used to be implemented by a built-in module called strop, but strop is now obsolete itself. Inside the file string.py I couldn't find the source code for translate. Where could it be? -- http://mail.python.org/mailman/listinfo/python-list