Click to See Complete Forum and Search --> : strings in python


clembot
01-23-2003, 07:37 PM
Is there a way around the fact that using "\b" in a string in IDLE makes that little box thing instead of a backspace, like it does in a normal shell?

ScRapZ_1
01-24-2003, 07:38 AM
No reason really, its kinda just there to let you know theres whitespace in the string. If you had a string test = "this is a test\b" and refrenced it just by typing test, it will print "this is a test\x08" - but if you type print test it will return "this is a test". The black square is interesting though, I'm assuming you're using the Windows python IDLE - but yeah, its just to say that theres whitespace in the string, and you cant exactly see whitespace. (Whitespace includes \n, \b, \t, \v, etc...)

TTFN,
Scrapz :p

clembot
01-24-2003, 03:20 PM
So let's say, hypothetically, i have a string stored in a variable, called var, and var is going to ende a sentence. If I put

print "Blah blah", var, "."

it puts a space between var and the period. Is there no way to fix that?

ChryZKoiD
01-24-2003, 10:07 PM
The C-style printf statement, in the form of python:
print "%s is a number %d!" % ("Python", 1)

This should give you more control over what you print.

clembot
01-24-2003, 11:28 PM
Hey, that works. Thanks.