variables within variables

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Thu Oct 26 06:37:22 EDT 2000


<lars at stea.nu> wrote:

>I'm writing a script for burning CD's
>
>I vant to set some variables like:
>
>cddev = /dev/cdrom
>cdrdev = 0,1,0
>speed = input("Enter speed: ")
>
>and then create a new variable like:
>
>cdcopy = "cdrecord - v speed=",speed , "dev=",cdrdev, "-isoimage", cddev

How about something like:

cddev = "/dev/cdrom"
cdrdev = "0,1,0"
speed = input("Enter speed: ")
cdcopy = "cdrecord - v speed=%s dev=%s -isoimage %s" % (speed, cdrdev,
cddev)

(not tested!)
>
>I've done this with def cdrecord(speed,cdrdev,cddev) and so forth.
>
>I can then print :
>
>print cdcopy
>
>but the word "Null" is appended to the end of the line.
>
>Then it doesn't work to execute:
>
>posix.system(cdrecord).
>
>Can anyone please explain a way to do this?
>
>Lars at stea.nu
>
>www.stea.nu
>
>
>

--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants





More information about the Python-list mailing list