create a string of variable lenght

Tracubik affdfsdfdsfsd at b.com
Sun Jan 31 07:07:55 EST 2010


Hi all,

i want to print on linux console (terminal) a message like this one:

********************************
error message of variable lenght
********************************

to print the asterisks line i do this:

def StringOfAsterisks(myString):
    asterisksString = "*"
    for i in range(1,len(myString):
       asterisksString += "*"
    print asterisksString

so i create the asterisksString of the lenght i need

There is a better way of creating asterisksString?

the code seem to work for me, but it doesn't work properly if in errorMsg 
there is some "esotic" char like euro char (€):

>>> euro = "€"
>>> len(euro)
3

how i can solve this?

Thank you all in advance and sorry for my bad english
Nico



More information about the Python-list mailing list