newbie - insert variable in pathname

Tim Golden tim.golden at viacom-outdoor.co.uk
Fri May 13 11:24:21 EDT 2005


[plsullivan63 at gmail.com]
| 
| Hello all,
| I have a username variable luser:
| 
| luser = win32api.GetUserName
| 
| I need to insert it into the following to replace the hardcoded
| "johndoe" in the pathname of GIS.GIS.Parcels:
| 
| GIS_GIS_Parcels = "Database
| Connections\\johndoe at GIS_srv-earth.sde\\GIS.GIS.Cadastral\\GIS
| .GIS.Parcels"

Just in case that's real code you've posted, you
should have:

luser = win32api.GetUserName () # note the brackets

otherwise you're simply binding the function
object to the name luser and not the result of
calling it.

But as to your actual question, you want to do something
like this:

x = "GIS_GIS_blah_blah\\%s at GIS_blah_blah" % luser

ie use %s within a string as a placeholder for the luser
string.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list