[Tutor] print variable in quotes

Gerrit Holl gerrit@nl.linux.org
Sat Feb 22 11:41:00 2003


Gerrit Holl schreef op zaterdag 22 februari om 13:22:13 +0000:
> reavey schreef op zaterdag 22 februari om 12:54:15 +0000:
> > hi
> > I need help printing a variable in quotes.
> > pre = "FGRTPQMK"
> > suf = "ack"
> > for elem in pre:
> >    print "echo      " elem+suf
> > 
> > I'd like to get the variable elem+suf in double qoutations?
> > The output I'd like to see:
> > echo  "Fack"
> > echo   "Gack"
> > is to be read by a screensaver called phosphor and used in an elem 
> > school to
> > reinforce an early reading concept using word families.
> 
>  36 >>> a="Monty Python's flying circus"
>  37 >>> print a
> Monty Python's flying circus
>  38 >>> print repr(a)
> "Monty Python's flying circus"
>  39 >>> print `a`
> "Monty Python's flying circus"

One more way:
 18 >>> print "%r" % a
'This is a  s t r i n g'

yours,
Gerrit.

-- 
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/