String changing on the fly
Batista, Facundo
FBatista at uniFON.com.ar
Wed Oct 20 12:49:54 EDT 2004
[elie at flashmail.com]
#- My users are using other scripting launguage to write scripts. They
#- are used to write somthing like (keeping it simple)
#- T = 100
#- do_action ('It cost $T dollars')
#-
#- where the above syntax ('It cost $T dollars') is interperted as ('It
#- cost 100 dollars').
>>> def do_action(s):
print s
>>> T = 100
>>> do_action('It cost %s dollars' % T)
It cost 100 dollars
Only note that the string is not changed (strings are immutable in Python),
but a new string is created.
. Facundo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20041020/9e1779ed/attachment.html>
More information about the Python-list
mailing list