On Thu, 10 Feb 2005 19:28:26 -0000, Alan Gauld <[EMAIL PROTECTED]> wrote: > > Although it's worse with: > > newstr = s + ' ' + str(n) + ' ' + str(r) > > You could try: > > newstr = s + ' ' + `n` + ' ' + `r` > > if you think thats better. > But `` is different to str() for some types. > > Personally I prefer the formatting approach. > > > But in my mind nothing beats the Perl statement: > > newstr = "$s $n $r"; > > Perl is king of string processing in modern scripting, > without a doubt. But even here the $ prefix could have > been used for that specific purpose without insisting > it be used everywhere else! > > BTW Anyone recall how Ruby does this?
I don't know ruby at all, but a quick google and 30 interpreter seconds later: irb(main):001:0> x = 12 => 12 irb(main):002:0> '$x' => "$x" irb(main):003:0> "$x" => "$x" irb(main):004:0> "#{$x}" => "" irb(main):005:0> "#{x}" => "12" irb(main):006:0> '#{x}' => "#{x}" so "#{<variable}" seems to do it. The googling shows that there are a myriad of other ways, which I haven't even looked at. They all seem to involve #{[symbol]<variable>} . Peace Bill Mill bill.mill at gmail.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor