print and % operator

Ruchika ruchika_khera at hotmail.com
Thu Sep 9 01:43:26 EDT 2004


Hi,

I am new to Python, so this may be a very simple question for most of
you. What does the % operator stand for in Python? I came across a
script that uses the % operator as follows -

def sync(delf,name):
    os.popen3( 'P4 -s sync -f %s' % name)

I would suspect that this just replaces the %s with the value of name.
Is % before name required? Should there be a space between % and name?

On a similar note, how can I print the value of name using the print
statement? Should print %name print the value of name?

Most of the time, when I add some print statements to my script I get
Autoindent error. Can someone tell me what this error is and how to
fix it?

Thanks for your help.

Ruchika



More information about the Python-list mailing list