delimiting text file??
Gordon McMillan
gmcm at hypernet.com
Thu Oct 14 16:07:19 EDT 1999
Gerrit Holl wrote:
> Aahz Maruch:
...
> > delimitedString = string[:x] + "," + string[x:]
> >
> > That's a rather lame way to do it; as you learn more about
> > Python, you'll come across better ways.
>
> Is it? I think I've learned more about Python than Jim has
> (already finished Learning python, and I'm waiting for
> Programming TkInter with Python now), but I don't know a better
> way than this?
For inserting a character now and then this is fine. But if
you're doing a lot of it to one string, then string.split /
string.join will be both more elegant and more efficient.
- Gordon
More information about the Python-list
mailing list