[Python-Dev] String methods... finally

Tim Peters tim_one at email.msn.com
Sat Jun 12 20:28:18 CEST 1999


[Tim]
> expandtabs is used frequently in IDLE and even pyclbr.py now.
> Curiously, though, they almost never want the tab-expanded string,
> but rather its len.

[/F]
> looked in stropmodule.c lately:
>
> static PyObject *
> strop_expandtabs(self, args)
> ...
>  /* First pass: determine size of output string */
> ...
>  /* Second pass: create output string and fill it */
> ...
>
> (btw, I originally wrote that code for pythonworks ;-)

Yes, it's nice code!  The irony was the source of my "curiously" <wink>.

> how about an "expandtabslength" method?

Na, it's very specialized, easy to spell by hand, and even IDLE/pyclbr don't
really need more speed in this area.



More information about the Python-Dev mailing list