print and % operator

Peter Hansen peter at engcorp.com
Thu Sep 9 07:00:05 EDT 2004


Ruchika wrote:
> 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?

You _really_ need to go through the tutorial... it answers
this question and others you have had and many others you
will have.

Also consider reading the main FAQ entries soon!

-Peter



More information about the Python-list mailing list