newb: Join two string variables

Fuzzyman fuzzyman at gmail.com
Tue Dec 5 19:02:36 EST 2006


johnny wrote:
> How do I join two string variables?
> I  want to do:  download_dir + filename.

That should do it. :-)

You can concatenate strings using the plus operator. For large number
of strings it is very inefficient. (Particularly in versions of Python
pre 2.4 or in IronPython.)

For these situations it is better to collect the strings in a list and
then join them using :

''.join(list_of_strings)

But for just two strings, plus is fine.

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> download_dir=r'c:/download/'
> filename =r'log.txt'
> 
> I want to get something like this:
> c:/download/log.txt




More information about the Python-list mailing list